简体   繁体   English

在 Xcode 上运行 C 程序时,这是它显示的错误 - 线程 1: EXC_BAD_ACCESS (code=1, address=0x68)

[英]While Running C program on Xcode 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.这正是我运行代码时 Xcode 显示的内容。

#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这是我正在编写的代码 它是直接从 Ansi C 中的 E.Balagurusamy Programming 中复制的。我什至尝试创建一个文本文件并将其放在代码的源文件夹中也更改了代码的执行文件夹,但它是未运行,当使用终端运行相同的代码时,它显示 -*分段错误:11

I just figured out that it was just a syntax error.我刚刚发现这只是一个语法错误。 I was using "W" insted of "w".我使用的是“W”而不是“w”。 thanks for helping out anyways.无论如何感谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM