gpt4 book ai didi

c - UNIX - 我的主要语法错误

转载 作者:太空宇宙 更新时间:2023-11-04 02:18:29 24 4
gpt4 key购买 nike

我在以下主语句中遇到语法错误...

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

错误显示“意外标记 `(' 附近的语法错误”。

但是,如您所见,此处有适量的括号。有什么问题?

谢谢!

更多代码:

/*Core Dump Program*/

#include <stdio.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <errno.h>


int main (int argc, char *argv[])
{
struct rlimit limit;

limit.rlim_cur = 0;
limit.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &limit) == -1){
printf("Error preventing core dump errno=%d\n", errno);
exit(10);
}
else {
printf("The current core limit is %llu\n", limit.rlim_cur);
printf("The core max limit is %llu\n", limit.rlim_max);
exit(0);
}
if (getrlimit(RLIMIT_FSIZE, &limit) == -1){
printf("getlimit() failed with errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %llu\n", limit.rlim_cur);
printf("The core max limit is %llu\n", limit.rlim_max);
exit(0);

}
if (getrlimit(RLIMIT_CPU, &limit) == -1){
exit(1);
}
else {
printf("The current core limit is %llu\n", limit.rlim_cur);
printf("The core max limit is %llu\n", limit.rlim_max);
exit(0);
}

if (getrlimit(RLIMIT_NOFILE, &limit) == -1){
printf("Error preventing core dump errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %llu\n", limit.rlim_cur);
printf("The core max limit is %llu\n", limit.rlim_max);
exit(0);
}

if (getrlimit(RLIMIT_NPROC, &limit) == -1){
printf("Error preventing core dump errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %llu\n", limit.rlim_cur);
printf("The core max limit is %llu\n", limit.rlim_max);
exit(0);

}
}

最佳答案

检查您的代码是否有“不可见”字符。根据文件的创建方式,可以获得在普通文本编辑器的正常操作模式下看不到的控制字符和/或 unicode 字符。许多编辑器都有“显示不可见字符”功能(或类似名称的功能)。一些编辑器甚至有一个功能可以找到并删除任何此类字符(例如,OS-X 的 Text Wrangler 中的“Zap Gremlins”。

关于c - UNIX - 我的主要语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4103199/

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