I have a text file that has the following lines:
(0,0) -180.000 77.500 -999.000 -999.000 -999.000 2740.831 45.000 -0.001 -0.001 0.000 458.138 45.000 -999.000
(1,0) -179.500 77.500 -999.000 -999.000 -999.000 2740.831 45.000 -0.001 -0.001 0.000 458.138 45.000 -999.000
(2,0) -179.000 77.500 -999.000 -999.000 -999.000 2740.831 45.000 -0.001 -0.001 0.000 458.138 45.000 -999.000
(3,0) -178.500 77.500 -999.000 -999.000 -999.000 2740.831 45.000 -0.001 -0.001 0.000 458.138 45.000 -999.000
...
...
(359,0) -0.500 77.500 -999.000 -999.000 -999.000 2740.831 45.000 -0.001 -0.001 0.000 458.138 45.000 -999.000
I am trying to put each line of this text file (buf) into an individual element of an array (buffarray) using the following program:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define PI 4*atan2(1,1)
int main(int argc, char *argv[]) {
FILE *fp;
char buf[200];
char *token;
char buffarray[223920];
char filename[150];
int i, j, k;
sscanf(argv[1], "%s", filename);
if ((fp = fopen(filename, "rt")) == NULL) {
printf("Failed in fopen: %s\n", filename);
return -1;
}
while (!feof(fp)) {
fgets(buf, 200, fp);
token = buf;
printf("buf is %s\n", buf);
buffarray++ = token;
}
}
How every when compiling this program I get an error message:
translate_ww3file.c: In function ‘int main(int, char**)’:
translate_ww3file.c:30:12: error: lvalue required as increment operand
buffarray++ = token;
^
How do I resolve this issue? I ideally want to create another text file where the lines are rearranged so that lines 180 to 359 from the original text are printed first in the new text file and then lines 1 to 179 are printing out afterwards in the new text file.