gpt4 book ai didi

c - 为什么我在 C 程序中收到杂散 '342' 错误?

转载 作者:行者123 更新时间:2023-11-30 18:49:33 26 4
gpt4 key购买 nike

我试图在 GNU/Linux 操作系统中编译 C 文件,但是当我尝试编译此代码时,编译器给出了一些错误。

我的op.c文件是这样的:

#include <stdio.h>

int main(int argc, char *argv[]){

int i;
for (i=0; i < argc; i++){
printf(“command line argument [%d] = %s \n”, i, argv[i]);
}

return 0;
}

当我尝试编译此代码时,出现这些错误。我该如何修复它们?

op.c: In function ‘main’:
op.c:6:3: error: stray ‘\342’ in program
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:3: error: stray ‘\200’ in program
op.c:6:3: error: stray ‘\234’ in program
op.c:6:13: error: ‘command’ undeclared (first use in this function)
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:13: note: each undeclared identifier is reported only once for each function it appears in
op.c:6:21: error: expected ‘)’ before ‘line’
printf(“command line argument [%d] = %s \n”, i, argv[i]);
^
op.c:6:21: error: stray ‘\’ in program
op.c:6:21: error: stray ‘\342’ in program
op.c:6:21: error: stray ‘\200’ in program
op.c:6:21: error: stray ‘\235’ in program

最佳答案

在 C 中使用正确的引号表示字符串。

printf("command line argument [%d] = %s \n", i, argv[i]);

而不是

printf(“command line argument [%d] = %s \n”, i, argv[i]);

关于c - 为什么我在 C 程序中收到杂散 '342' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42536924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com