I am starting to studying C and I already run into few problems. I want to parse a file and store the results of each line in a structure. My structure looks like:
struct record {
char x[100];
}
Then, whenever I use strtok to parse a line in some file.txt,
struct record R;
...
char *token;
token = strtok(line, "\t");
token returns a pointer to the string and whenever I print it, it is correct string. I want to assign token to x, such as R.x = token, but I get an error, "char x[100] is not assignable". Is it possible to convert this pointer token to actual char array or what would be the best way to store the results into the structure?
memcpy()to fill it with the data you want it to contain.