read text file in xcode

Posted by danielDhobbs on Stack Overflow See other posts from Stack Overflow or by danielDhobbs
Published on 2010-05-23T13:38:07Z Indexed on 2010/05/23 13:40 UTC
Read the original article Hit count: 316

Filed under:
|

hello. i tried to read text file in xcode but this "EXC_BAD_ACCESS message showed up when i tried to build my program

here is my code and i put inputA.txt file in the same folder with project file my friend told me that i should put txt file in debug folder is this why i cannot read 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"); //fp = fopen("inputB.txt", "r"); //fp = fopen("inputC.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++;
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about mac