While Running C program on X-Code this is what it is showing up in error - Thread 1: EXC_BAD_ACCESS (code=1, address=0x68)

This is Exactly what XCode is showing when I'm running the code.

#include <stdio.h>

int main()
{
    FILE *f1;
    char c;

    printf("Data Input\n\n");

    f1 = fopen("/Users/karanjeetsinghbagga/Desktop/File Management in C/Fille Management in C/INPUT.txt", "W");

    while((c=getchar())!= EOF)
        putc(c,f1);

    fclose(f1);
    printf("\nData Output\n\n");

    f1 = fopen("/Users/karanjeetsinghbagga/Desktop/File Management in C/Fille Management in C/INPUT.txt", "R");

    while((c=getchar()) !=EOF)
        printf("%c",c);

    fclose(f1);         
    return 0;
}

This is the code which I was writing And it is directly copied from E.Balagurusamy Programming in Ansi C. I tried even creating a text file and putting it in the source folder of the code also changed the execution folder for the code but it is not running and when the same code is being run using terminal it is showing -* Segmentation fault: 11

728x90

1 Answers While Running C program on X-Code this is what it is showing up in error - Thread 1: EXC_BAD_ACCESS (code=1, address=0x68)

I just figured out that it was just a syntax error. I was using "W" insted of "w". thanks for helping out anyways.

1 year ago