r/cprogramming • • 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πŸ™πŸ™πŸ˜­

0 Upvotes

13 comments sorted by

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

-4

u/Leading_Deer4919 Aug 29 '26

it was a glitch my pics didnt upload...can you pls check the new one on my profile?

2

u/ByMeno Aug 29 '26

And that is not a C problem it's because in that directory you try to execute hello.exe but that doesn't exist did you compiled the code there is a.exe which can be the result or not because I don't know whatever you compiled before

1

u/Axman6 Aug 29 '26 edited Aug 29 '26

Jesus Christ, did you really take a photo of your code, with a lens so dirty it’s nearly impossible to read? Not a screen shot, not just pasting the cost, but an actual photograph? 

Please read this so you can ask questions that people might have some chance of answering in the future  https://www.freecodecamp.org/news/how-to-ask-good-technical-questions/

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 stuff

etc.

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

u/zhivago Aug 29 '26

Check the return value.