Well you I understand that you are dealing with an array of strings, if so each string can hold up to 48 characters, (49 if you get rid of the '
'
fgets()
adds).
This should work:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LEN 50
#define MAX_LINES 3
int readMovies(FILE *file, char Names[3][50]) {
int i;
FILE *file = fopen("Names.txt", "r")
if (myFile == NULL) {
printf("Error");
exit(-1);
}
for(i = 0; i < MAX_LINES; i++) {
fgets(Names[i],MAX_LEN, file);
}
/* ... */
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…