This is my code:
when i compile and run it, it stops working and doesn't printf the integer.Code:int main() { int num; printf("Please enter a number: "); scanf("%d", num); printf("%d\n", num); return 0; }
This is my code:
when i compile and run it, it stops working and doesn't printf the integer.Code:int main() { int num; printf("Please enter a number: "); scanf("%d", num); printf("%d\n", num); return 0; }
You're missing that &. The & gives the address of a variable. scanf needs the address of num, so it knows where to store the number it read in from the user.Code:scanf("%d", &num);
Thanks =)
which means the problem probably has to do with the statements before - since your printf() is called correctly. You may find this link helpful in the future. I find it handy.
Warning: Opinions subject to change without notice
The C Library Reference Guide
Understand the fundamentals
Then have some more fun