The problem here is that whenever I change the contents of studName the contents inside studArr change too.
If the input looks like this (AAA,BBB,CCC) I first store AAA inside studName and then store studName into studArr.
I'm trying to make:
studArr[0][1] = "AAA"
studArr[0][2] = "BBB"
studArr[0][3] = "CCC
but when I use this code all of them equal CCC. Is there a way I can fix this?
for (j = 0; j < NumCourses + 1; j++){
i = 0;
k = 0;
while ((c = fgetc(ifp)) != ')'){
if (c == ','){
studName[3] = '\0'; // ends sting with null char
studArr[j][k+1] = studName;
k++;
i = 0;
}
else{
studName[i] = c;
i++;
}
}
studName[3] = '\0'; // ends sting with null char
studArr[j][k+1] = studName; // store studName in studArr
}