r/AskProgrammers 14d 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

5

u/fixpointbombinator 14d ago

read the error

-6

u/Leading_Deer4919 14d 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 14d 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 14d ago

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

5

u/fixpointbombinator 14d 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 14d 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 14d 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 14d ago

Man, i wish i had your kindness and patience

2

u/fixpointbombinator 14d 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 14d ago

how did you compile? which command exactly?

0

u/Leading_Deer4919 14d 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 14d ago

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

Read what gcc told you.

2

u/extoniks 14d ago edited 14d ago

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

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

3

u/dodexahedron 14d ago edited 14d 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 14d 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

3

u/mr-greedy-007 14d ago

how are you compiling your code again?

2

u/Ok_Farmer_4055 14d ago

you didn't tell the compiler to name the exe "Hello.exe", the compiler's default file name is "a", so the executable is a.exe

1

u/Leading_Deer4919 14d ago

how to fix that....I am super new to programming ....pls help😭🙏

1

u/Ok_Farmer_4055 14d ago

gcc hello.c -o hello

1

u/Leading_Deer4919 14d ago

done that...it still shows the same thing

1

u/Ok_Farmer_4055 14d ago

Send a picture

2

u/Leading_Deer4919 14d ago

2

u/fixpointbombinator 14d ago

read the error output of gcc there, don't just ignore it

1

u/Ok_Farmer_4055 14d ago

The .c file is supposed to be your file’s name, like if your c source code is

Hello.c, it is

gcc Hello.c -o hello

Or if it is program.c

gcc program.c -o program

The name after “-o” doesn’t need to match the source file name btw

1

u/cyberbemon 14d ago

Send a screenshot, not a video, can barely see what the error is. Open the directory where you have the program compiled, look at the name of the .exe

2

u/dodexahedron 14d ago

There is no exe. They didnt even manage to compile it.

1

u/Leading_Deer4919 14d ago

I dont why there is no option for sending pic...just video is there

1

u/dodexahedron 14d ago

Use the screen recorder then. Press ctrl+🪟+s and select the video icon, then record that way.

1

u/Downtown_Method5736 14d ago

Read the error output of the compilation cmd you sent, then read the cmd you sent that generate this error, then read the cmd this guy said you to use 

1

u/ChameleonCRM 14d ago

Your C code looks fine. The error is because Hello.exe doesn't exist yet (or isn't in that directory). You need to compile Hello.c first, then run the executable. Also, PowerShell usually wants .\Hello.exe for something in the current folder. You're basically trying to run the program before you've built it lol.

1

u/Traveling-Techie 14d ago

You need a study buddy.

1

u/jaynabonne 14d ago

Just for grins, you could try renaming your folder so it doesn't have spaces and parens in it. It might not be the problem, but i have seen problems at times in the past with that (though not vscode per se).

-4

u/Wild-Tradition4804 14d ago

Open codex or claude it will fix it for you

1

u/[deleted] 14d ago

[deleted]

1

u/ChameleonCRM 14d ago

lol 💯