| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello everyone. I'n new to C, but even newer to this community. This is my first post. Here's my problem (you knew that was coming.) I feel that I understand the very, very basics of C, but every time I try to execute a compiled program it opens a blank, black screen and then returns to my compiler. I think it might be because I don't have some of the "standard library" Is that even possible. Any comments are greatly appriciated!
|
|
#2
|
|||
|
|||
|
//Basic program template for chapter one using int main()
// //insert description here // #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszArgs[]) { //insert code here //end of inserted code //wait until user is ready before terminating program //to allow the user to see the program results system("PAUSE"); return 0; } This is the basic template from a book into which ive been shoving my code. Do you have any include files? Does even getting it to write some text fail? |
|
#3
|
||||
|
||||
|
-PreemptFallacy-
yes system ("PAUSE") works for me too Kolokol but you could just create a variable like this as well, but basically its all in your personal preference =Þ i prefer this way most of the time.
Code:
int main(void)
{
int exit;
code
cin>>exit
return 0;
}
By the way PreemptFallacy the program opens then closes "in most cases" because your code is finished, the computer went through every line of code and returned 0 and then closed the window,(this is if you are running the program for the compiler that is!!!)(If you do not have the compiler open and you try to run the program and then it shuts off and goes to the compiler than you probably have an error in your code itself and needs to be debuged!!!) If there were something wrong most compilers would let you know there was a break and ask you if you wanted to debug, but I only have two compilers so Im not to sure on that one. =) I wouldn't think it is your compilers libraries because if it was that, you usually aren't able to compile the program and run it, so I think your ok there. Last edited by Geo.Garnett : September 1st, 2005 at 03:02 PM. Reason: Forgot something important |
|
#4
|
|||
|
|||
|
Personally I find it better to open a command window (start, run, "cmd", enter ... that is, for Windows XP
). Then move to the directory of the executable, and enter the name.This will show you the output without changing the code and pressing a key to finish your program every time... Just keep the command window open. |
|
#5
|
|||
|
|||
|
Quote:
Yes, I do have include files, and generally speaking, no it does not write text. Thanks for your help! |
|
#6
|
|||
|
|||
|
Quote:
I use Dev-C++, if that helps you any. This is the code I tried to run. Very simple, just to see if it would work. #include <stdio.h> int main() { printf("Output here."\n"); return 0; } I ran this through a command line, not my compiler and got the same result; I did however find several files which are considered to be "standard" as a sub-folder, so I know that's not the problem. Any other suggestions? |
|
#7
|
|||
|
|||
|
Quote:
Thank you so much!! I did this with the simple output here program, and it displayed "output here" and didn't terminate. Thanks!! |
|
#8
|
|||
|
|||
|
You're welcome.
It is always frustrating when things don't go as you would expect and you can't find the reason. Good luck with the rest of your C development, and ... if you bump into any other problems: you're not so new to this community anymore ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > A beginer's question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|