Thread1: EXC_BAD_ACCESS (code=1,address=0x68)

Asked

Viewed 246 times

0

I am having this problem in ide Xcode. On line 8 the warning appears

Thread1: EXC_BAD_ACCESS (code=1,address=0x68)

The file . txt is in the same folder as the main.

void construir1(struct elemento **P_inicio){
    FILE *arq;
    struct elemento *p1;
    char c;

    arq=fopen("t1.txt", "r");
    *P_inicio = NULL;
    while ((c= getc(arq))!=EOF) {
        if (c!='\n') {
            p1 = malloc(sizeof(struct elemento));
            p1->x = c;
            p1->prox = *P_inicio;
            *P_inicio= p1;
        }
    }
    fclose(arq);
    return;
};
  • I compiled the same code on Linux using gcc and it works perfectly. It really is something from Xcode or Mac, if any know what it can be and how to solve it would be of great help.

1 answer

0


It really was something from the Xcode, it wasn’t pulling the txt. To resolve I went to "Product > Scheme > Edit Scheme > Run > Working Directory" and Linkei the folder where the code and txt is. By doing this the program ran normally on Mac.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.