I tried to read the text file in xcode, but this "EXC_BAD_ACCESS message appeared when I tried to create my program
here is my code and I paste the inputA.txt file into the same folder with the project file my friend told me that I have to put the txt file in the folder for debugging, so I can not read the txt file in this code? please help me...
macbook user.
int main (int argc, const char * argv[]) {
FILE* fp;
char mychar;
char arr[50][2] = {0, };
int i = 0;
int j, k;
graphType* G_;
G_ = (graphType*)malloc(sizeof(graphType));
Create(G_);
fp = fopen("inputA.txt", "r");
while(1){
for(j = 0 ; j < 2 ; j++){
mychar = fgetc(fp);
if(mychar == EOF)
break;
else if(mychar == ' ')
continue;
arr[i][j] = mychar;
}
i++;
}
source
share