Opening a file from command line arguments in C
问题 I want my C program to ask the user to type the name of the file they want to open and print the contents of that file to the screen. I am working from the C tutorial and have the following code so far. But when I execute it, it doesn't actually allow me to enter the file name. (I get the 'press any button to continue', I am using codeblocks) What am I doing wrong here? #include <stdio.h> int main ( int argc, char *argv[] ) { printf("Enter the file name: \n"); //scanf if ( argc != 2 ) /* argc