c - 预期冒号错误问题

标签 c

很难弄清楚为什么我会得到预期的“;”在函数 parseString 之后。

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct Integer50
{
// a dynamically allocated array to hold a 50
// digit integer, stored in reverse order
int *digits;
} Integer50;

main() {
    Integer50 * parseString(char * str)
    { //error is on this colon
        return NULL;
    }
}

最佳答案

这个:

main() {
    Integer50 * parseString(char * str)
    { //error is on this colon
        return NULL;
    }
}

应替换为:

Integer50 * parseString(char * str)
{ //error is on this colon
    return NULL;
} 

int main() {
    //If you need to call that `parseString` function call it here
}

所以,C 不支持函数内函数。 main 是一个函数,parseString 是另一个函数。这就是问题所在。

关于c - 预期冒号错误问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43100889/

相关文章:

c - 在OVS源代码中添加新的实验者匹配字段

c - 如何在c中选择矩阵中的数字?

c - 地址 sanitizer 和 __attribute(section ("mysection")) 失败

c - 如何在特定位置写入文件?

c - 将从 C 例程分配的数组传递给 Ada

c - C 中 Raspberry PI 串行通信中的奇偶校验设置问题

c - 使用 Unix 域套接字的 IPC

c++ - 线程缓存对象引用

c - 用于维护状态的 void*...(C 编程)

C "block"插入字符