使用未声明的标识符' a'

时间:2017-02-23 20:08:35

标签: c

我正在尝试编写这样的C程序,但编译器会一直报告错误,因为它无法理解标识符' 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);

我使用 gcc 作为编译器。

1 个答案:

答案 0 :(得分:1)

您使用了错误的引号,可能是因为您从某处复制粘贴了它。而不是

Processing TPA for deps entry [Microsoft.ApplicationInsights.AspNetCore, 2.0.0, lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll]
  Considering entry [Microsoft.ApplicationInsights.AspNetCore/2.0.0/lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll] and probe dir [/packagescache/x64]
The hash file is invalid [/packagescache/x64/Microsoft.ApplicationInsights.AspNetCore/2.0.0/Microsoft.ApplicationInsights.AspNetCore.2.0.0.nupkg.sha512]
    Skipping... match hash failed
  Considering entry [Microsoft.ApplicationInsights.AspNetCore/2.0.0/lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll] and probe dir [/packagescache]
The hash file is invalid [/packagescache/Microsoft.ApplicationInsights.AspNetCore/2.0.0/Microsoft.ApplicationInsights.AspNetCore.2.0.0.nupkg.sha512]
    Skipping... match hash failed
Error: assembly specified in the dependencies manifest was not found -- package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.0.0', path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll'

你想要

’a’