I am trying to create an array of fixed-length strings in C, but you had minor problems. The problem I am facing is that I get a segmentation error.
Here is the goal of my program: I would like to set the array strings by index using data read from a text file. Here is the gist of my current code (I apologize that I could not add all my code, but it is quite long and most likely will just cause confusion):
//"n" is set at run time, and 256 is the length I would like the individual strings to be
char (*stringArray[n])[256];
char currentString[256];
//"inputFile" is a pointer to a FILE object (a .txt file)
fread(¤tString, 256, 1, inputFile);
//I would like to set the string at index 0 to the data that was just read in from the inputFile
strcpy(stringArray[i], ¤tString);
source
share