Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c read file from command line

You can use as your main function:
int main(int argc, char **argv) 

So, if you entered to run your program:
C:myprogram myfile.txt

argc will be 2
argv[0] will be myprogram
argv[1] will be myfile.txt

To read the file:
FILE *f = fopen(argv[1], "r");
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #read #file #command #line
ADD COMMENT
Topic
Name
7+5 =