yessir, and that was my next idea. But I wasn't sure how I'd implement that. As in, how would I know it's the new line?
for example my function for this piece of code for this so far is this...
Code:
char **open_classes_taken(int *count){
FILE *fp;
char buffer[100];
char *temp;
int class_count = 0;
char **names = malloc (sizeof(char*));
if ( (fp = fopen("hw11-data.csv", "r" )) == NULL )
{
printf("Couldn't open file\n");
exit(1);
}
while(fgets(buffer, sizeof(buffer), fp))
{
for(temp = strtok(buffer, ",") ; temp != NULL; temp = strtok(NULL,","))
{
names[class_count] = malloc(strlen(temp) + 1);
strcpy(names[class_count], temp);
class_count++;
names = realloc(names, ((class_count)+1)* sizeof(char*));
}
}
fclose(fp);
*count = class_count;
return names;
}
and if you notice, I was leaving the newlines in there and was going to basically say if it's a newline, compare to the other array of strings stored (which is going to be an array from a file that shows prerequisites). Opening these files seems like they will be able to both use the same function if I do this.
Anywho, back to your question. Yes we've learned structures, but when thinking about that, I was just unsure how I would find the newline. Would it be similar to how my code is written now, just using structures instead?