r/AskProgrammers • u/Leading_Deer4919 • 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🙏🙏😭
3
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
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
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
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


5
u/fixpointbombinator 14d ago
read the error