Horje
c read file from command line Code Example
read from command line c
#include <stdio.h>

int main(int argc, char **argv) {
    for (int i = 0; i < argc; ++i) {
        printf("argv[%d]: %s\n", i, argv[i]);
    }
}

/*
	[birryree@lilun c_code]$ ./a.out hello there
	argv[0]: ./a.out
	argv[1]: hello
	argv[2]: there
*/
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");




C

Related
UTC offset upper limit Code Example UTC offset upper limit Code Example
MongoDb Read Code Example MongoDb Read Code Example
networkx remove attributes Code Example networkx remove attributes Code Example
YOUNG SEX PARTY underground  collection Code Example YOUNG SEX PARTY underground collection Code Example
iulia vântur Code Example iulia vântur Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10