Problem with a verx simple c program.
Helo.
I wrote a very simple program in Kate: #include <stdio.h> main () { int number; printf("A number please.\n"); scanf("%d",number); printf("%d\n",number); return 0; } I compiled it with gcc, and then i cant execute it. It says "Segmentation fault" |
not sure you can return an integer with out specifying main returns it first
Code:
int main() { |
you should do
Code:
scanf("%d",&number); |
Quote:
|
I hope you didn't get the impression that & is a "magic" operator to use with scanf. If you have gotten to the end of any C tutorial without learning about pointers please find a better a tutorial.
|
Quote:
|
All times are GMT -5. The time now is 04:46 AM. |