There are actually three segmentations here:
fread(content,1,lsize,file_pointer); strcpy(temp,buffer); row = strtok(temp,"\n");
The first is fread() , which is trying to write to memory that does not yet exist in relation to your process.
The second is strcpy() , (expounding the first), which you are trying to copy into a pointer that points to nothing. For temp , no memory is statically or dynamically allocated (other than a pointer reference).
Fix this by changing temp to look like this (assigning it statically):
char temp[1024];
Or use malloc() to dynamically allocate memory for it (as well as for other pointers, so they actually point to something), similarly for content . If you know the required buffer size at compile time, use static allocation. If not, use malloc() . βKnowingβ is the subject of another question.
The third is strtok() , which will modify temp en situ (in place), which, obviously, cannot do, since temp never stood out. In any case, do not expect temp be the same once strtok() is executed with it. By the name of the variable, I assume you know that.
In addition, initializing a pointer is not the same as allocating memory for it:
char *temp = NULL; // temp is initialized char *temp = (char *) malloc(size); // temp is allocated if malloc returns agreeably, cast return to not break c++
Finally, please get used to using strncpy() over strcpy() , its much safer.