-2
このようなCプログラムを作成しようとしていますが、コンパイラは識別子 'a'を理解できないというエラーを報告し続けます。誰かがここで何がうまくいかないか教えてもらえますか?私はコンパイラとしてgccのを使用宣言されていない識別子 'a'の使用
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
int main() {
char buffer[200];
memset(buffer,’a’,200);
int fd = open("test.txt", O_CREAT | O_RDWR);
write(fd, buffer, 200);
lseek(fd, 0, SEEK_SET);
read(fd, buffer, 100);
lseek(fd, 500, SEEK_CUR);
write(fd, buffer, 100);
}
/Users/messfish/Desktop/os1.c:9:18: error: non-ASCII characters are not allowed
outside of literals and identifiers
memset(buffer,’a’,200);
^
/Users/messfish/Desktop/os1.c:9:22: error: non-ASCII characters are not allowed
outside of literals and identifiers
memset(buffer,’a’,200);
^
/Users/messfish/Desktop/os1.c:9:21: error: use of undeclared identifier 'a'
memset(buffer,’a’,200);
: は、ここでは、コードおよびエラーです。
をしたいです。あなたはそれをコピー/ペーストするのではなく、*** ''a'' ***とタイプするべきです。 – jww
エラーの戻り値、特に 'open'、' read'、および 'write'をチェックするとうまくいくでしょう。 – donjuedo