Advertisement
rfmonk

beej05exception_and_fix.c

Oct 21st, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. int main(void)
  2. {
  3.     int i;
  4.     i = 2; /* assign the value 2 into the variable i */
  5.     printf("Hello, World!  The value of i is %d, okay?\n", i);
  6.     return 0;
  7. }
  8.  
  9. /* this is what it returns
  10. $ gcc beej05.c -o HelloWorld
  11. beej05.c: In function ‘main’:
  12. beej05.c:7:17: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
  13.                  printf("Hello, World!  The value of i is %d, okay?\n", i);
  14.  
  15. I believe this is identical to http://beej.us/guide/bgc/output/html/multipage/sve.html
  16. part 3.1 second example.
  17. His output differs from mine.
  18. according to the guide its supposed to print:
  19. Hello, World!  The value of i is 2, okay?
  20.  
  21. Googling for the warning shows this to be easily fixable with the include
  22. #include <stdio.h>
  23.  
  24. gcc beej05.c -o HelloWorld
  25. ./HelloWorld
  26. Hello, World!  The value of i is 2, okay?
  27. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement