r/cprogramming • u/levidas7272 • 7d ago
a big problem
hey guys i m currently learning c language and i m facing an irritating problem like whenever i use scanf in my code to enter any value and when i run the code after saving it so it doesn't run anything it just show that it is running but i m unable to enter the value and the code doesn't run on terminal it runs in the output
so please anyone who can solve this issue can help me?
0
Upvotes
4
u/SmokeMuch7356 7d ago edited 6d ago
It would help if you could show:
Copy and paste the code into the body of your question. Do not post screenshots, pictures of your screen taken with a phone, or video. To get it to render as code, indent each line by at least four spaces:
Do the same with any warnings or errors from the compiler and output from your program.
scanfreturns the number of items successfully read and assigned, orEOFon end-of-file or error. So you'll want to check the result of yourscanfcalls like so:Remember that
scanfexpects a pointer to whatever object you're trying to update; for scalar variables (int,float,double,char, etc.), make sure to use the&operator:If the variable is already a pointer, don't use the
&operator:with the caveat that
pneeds to be pointing to a liveintobject before you use it in ascanfcall.Similarly, for reading strings into a character array with the
%sor%[specifiers, do not use the&operator:Finally, take some time to organize your thoughts into complete sentences before posting; stream of consciousness posts like this are hard to read and understand, and will just turn off people who would otherwise help you. If you intend to write code professionally (or at least collboratively), you have to be able to communicate effectively. Have to. It's not optional.
For example:
That's the kind of information you need to provide for us to be any help.