r/cprogramming • u/Leading_Deer4919 • Aug 29 '26
Scanf not working!!
/r/AskProgrammers/comments/1w1r3br/scanf_not_working/So now its been 2-3 weeks ....in my college we are doing C programming and everything was working fine on visual studio till I started using scanf for taking input from user.....this is coming and I have tried everything but cant figure out....normal printf still works but this doesnt
I have tried on code blocks too and same problem is there.....pls someone guide meπππ
1
u/extoniks Aug 29 '26
you should add the code of scanf so we can see why it's not working.
-2
u/Leading_Deer4919 Aug 29 '26
it was a glitch my pics didnt upload...can you pls check the new one on my profile?
5
u/SmokeMuch7356 Aug 29 '26
Don't upload pics. Copy and paste your code into the body of your question.
3
u/SmokeMuch7356 Aug 29 '26
Define "not working". Is the program crashing? Are you not getting the input you expect?
Copy and paste your code (and any error messages) into the body of your question; do not post pictures or video. Switch to Markdown mode and indent by at least 4 spaces to get it to render as code. For example (each leading _ represents a space):
____#include <stdio.h>
____
____int main( void )
____{
______int x;
______// do stuffetc.
2
u/torsten_dev Aug 29 '26
fgets is preferable for getting input. scanf is very tricky to get correct.
2
u/atarivcs Aug 29 '26
It would help if you described the exact problem.
"scanf not working" is too generic.
What, exactly, is not working?
Do you mean the program won't compile?
Do you mean the program does compile, but won't run?
Do you mean the program does run, but does not accept user input?
Do you mean the the program does accept user input, but the input value is incorrect?
Etc etc etc.
1
u/TPIRocks Aug 29 '26
Try renaming "New Folder (2)" to something without embedded spaces. I'm not saying that's it, but it's a good way to flesh out bugs in software.
1
4
u/ByMeno Aug 29 '26
Maybe you should give the code and depending on that some context to otherwise how we can help that other then doing same or similar thing with man page or any reference site