Tuesday, July 28, 2009

Why is my c compiler showing 312 lines instead of 4 lines ?

iam a beginner, am trying to display "hello word" ; but it reported no errors , no warnings . I could not run it . Pls see below .:


#include%26lt;stdio.h%26gt;


void main()


{


printf("hello world") ;


}

Why is my c compiler showing 312 lines instead of 4 lines ?
#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;





void main()


{


clrscr();


printf("\n Hello world");


getch();


}





u need to use getch(), it waits for the user to get input, hence giving u enough time to read message on displayed on screen.





if u need help mail me.
Reply:Regarding the line count: that #include %26lt;stdio.h%26gt; is the culprit. The number of lines reported includes the lines in that stdio.h file.





Hope that helps.
Reply:That is a simple problem. The screen is coming and going very quickly. Type in this code:





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


//If your compiler is Dev-Cpp then type here: Using namespace std;


void main(){


printf("Hello World");


getch();


}





the header file "conio.h" has the function "getch():" which waits for the user to press return, before continuing.





Hope this helps.
Reply:look up the file stdio.h somewhere in ur TC file and you open it.





you will see the extra 308 lines there.





the compiler not only counts the number of lines you typed yourself, but also the ones you inculded, in this case





stdio.h





Hope it helps





Cheers


No comments:

Post a Comment