1.

Solve : Newbie question regarding C programming?

Answer»

Salutations all. I admit I'm SOMEWHAT hesitant to ask this, but it's the sort of problem where the answer is TUCKED away or simply non-existent because of it's rarity and lack of severity.

I wrote the standard "hello world" program in Dev-C++ version 4 and compiled it as per the instructions (I'm reading from the book, "Teach Yourself C in 21 Days") and it compiled and ran without errors. I'm using Windows XP, if that helps.

The problem isn't the fact that it worked, but the fact that the cmd.exe window, which it printed to, opened and closed within a split second. The book doesn't say anything about it, simply stating "Now you've printed 'hello world' to your SCREEN!". I know it can't be a problem with the code, so I'm wondering if it's a problem with either the settings on my operating system or the compiler.

Any help would be tremendously appreciated. It'll be hard to learn C without being able to view the results of my work.

Thank you.The problem comes from the program finishing right to the return 0; command. It's been so long since I've used Dev-C++ that I had to google it

so

Code: [Select]system("pause");
or use include conio.h and use the getch() method.
Code: [Select]#include <conio.h>
....
getch();Thank you very much, the system("pause"); did the trick.

Should have realized it would be something similar to that. I've worked a little bit with .bat files before, but being new to C I haven't yet fully realized the LEVEL in which a program works with the command line. And if that sounds like a really stupid newbie statement, well, I'm a really stupid newbie ^^'

Thanks again for the tip, odds are I'll never forget it ^.^You're welcome



Discussion

No Comment Found