C: Efficient way to read two files from the command line -


I am a new to learning C language and need help to read more than 1 file from command line after code Has been compiled using GCC. For example, if my code is compiled and outputs then you should run it like a.out FILEA FILEB so far I have it, but when I read another file another I try to add a loop FILEB I get a partition error, where is this error coming from?

  #include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; #include & lt; String.h & gt; Zero evalFile (four * s); Int main (int argc, char * argv) {FILE * fp1, * fp2; If (argc! = 3) {printf ("./progName fileName1.csv fileName2.txt"); } Fp1 = fopen (argv [1], "r"); FP2 = FOPN (RGR [2], "R"); While (fgets (buffer, size (buffer), FP1)! = Null () (if buffer [0] == "#") continues; EvalFile (buffer); }} Zero evalFile (char * s) {char * token, * del = "(,)"; Token = string (S, Dell); While (token! = Null) {token = stroke (tap, dell); }}  

You've written:

  fp1 = FOPIN (AGRC [1], "R"); FP2 = FOPN (RGC [2], "R");  

Your command line parameter is stored in argv , argc !
They are very different.

You want

  fp1 = fopen (argv [1], "r"); // argv, not argc fp2 = fopen (argv [2], "r"); // argv, argc no  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -