i do some simple C programming. i wonder after i run the coding, and no error, but the command window (black) just appear a second and then disappear. this is my simple codding
#include %26lt;stdio.h%26gt;
int main()
{
printf("hai");
return (0);
}
Hi all.. about the command window programming C?
The program is fine. If you see it prints "hai" to the screen and will come back to the code as you have not instructed to wait for your key-press.
Please add
#include%26lt;conio.h%26gt;
just below stdio.h declaration
%26amp;
add
getch();
just above return(0);
you can use void main() always if you do not return any value. Its a good habit and will reduce the code length. You can avoid this return line.
Hope this helps!!! All the best
Reply:Try:
#include %26lt;stdio.h%26gt;
int main()
{
printf("hai");
system("PAUSE"); /* Enter this line */
return (0);
}
Reply:this is because you created an error.
like if you typ 1/0, this same will occur
#include%26lt;iostream.h%26gt;
#include %26lt;stdio.h%26gt;
int main()
{
cout%26lt;%26lt;"hai";
return (0);
}
#include%26lt;iostream.h%26gt;
#include %26lt;stdio.h%26gt;
void main()
{
cout%26lt;%26lt;"hai";
}
It works either way
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment