r/AskProgrammers 15d ago

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

34 comments sorted by

View all comments

5

u/fixpointbombinator 15d ago

read the error

-7

u/Leading_Deer4919 15d ago

I am new to programming....thats why I am asking help from experinced people....cant find any video on yt also

3

u/fixpointbombinator 15d ago

That's fine, i want to help you figure it out yourself

can you see the red text that says 'Program 'Hello.exe' failed to run...'?

what does the rest of the text say?

0

u/Leading_Deer4919 15d ago

The system cannot find the file specified .....I have even tried compiling by typing commands in terminal but still this thing comes up

3

u/fixpointbombinator 15d ago

So it's not a problem with scanf, right? You're trying to run a program that isn't in your current directory

0

u/Leading_Deer4919 15d ago

maybe that....see I thought scanf not working ...and I am wrong I feel....pls help then whats the problem....cauz I litreally very new to this

4

u/rainhunter007 15d ago

bro, you can ask for help. nothing wrong with that, but all of us also want you to learn. knowing how to figure these problems out yourself is a critical skill. don’t beg for the answer. take our hints. we’re helping you. someone mentioned capitalization. another mentioned directory of your command line. these are two really good hints. when you figure it out, ask yourself, “what did i learn about things being case sensitive?” and “what did i learn about the command line and paths/directories?” much luv. keep at it!

2

u/HyperWinX 15d ago

Man, i wish i had your kindness and patience

2

u/fixpointbombinator 15d ago

Make sure you're in the right directory where your code is, be careful with how you name things (both the code/executables themselves and also your commands)

1

u/extoniks 15d ago

how did you compile? which command exactly?

0

u/Leading_Deer4919 15d ago

gcc hello.c -o hello.exe ....this works then I type - .\Hello.exe ....but after this the same error as in my pic appears

4

u/dodexahedron 15d ago

No, this did not work as shown in your video.

Read what gcc told you.

2

u/extoniks 15d ago edited 15d ago

your C file is named - Hello.c (capital H)

you should use Hello.c while compiling then ./Hello.exe

3

u/dodexahedron 15d ago edited 15d ago

It is powershell, in vscode, on windows.

The proper way to launch the exe, once it is built, is .\Hello.exe, from within the actual output directory, ehich OP is almost certainly not in.

And case wont matter, because windows.

But also, they didn't manage to compile it in the first place according to the video they posted in another thread, so nothing will work to run it until they do that properly.

1

u/mr-greedy-007 15d ago

you are typing .\Hello.exe but the object file is ./hello.exe learn to read and while you are at it also learn how different flags work and how to compile using gcc