Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

At the top of the main() function block, I coded: char source_file[200]; int cod

ID: 3627442 • Letter: A

Question

At the top of the main() function block, I coded:

char source_file[200];
int code;

// Get source code file name
printf("What is the input file name? ");
scanf("%s", source_file);
printf(" ");

When I compile this program in Unix, it crashes at runtime (doesn't even ask "What is the input file name"). When I compile in windows (using Visual Studio) it does not. If I replace the code in the above blockquote with #define source_file "somefile.txt" the program suddenly executes properly in Unix. 

Why doesn't my program execute when I use scanf() in Unix?

I am completely new to compiling/running programs in Unix. PLEASE let me know if you need any other information. It's a long/multi-file program which I can upload somewhere if necessary. Thank you for any help, I am completely stumped.

Also, I am using WinSCP.

Explanation / Answer

Problem solved via PM. It allows me to enter in a file name and accepts it and runs. It could be that WinSCP is causing the problems. My suggestion is to use PuTTY (download it at http://www.putty.org/). I've tested this on my school's system remotely just now via Putty as opposed to WinSCP and it worked fine; compiled and ran - the code you have posted. As a last resort If you are still having problems, you might want to try to use a system that is strongly connected and actually use a unix shell to run and compile your code. -B