c - 传递 'atoi' 的参数 1 使整数指针无需强制转换......任何人都可以帮助我

标签 c atoi

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
    int n;
    int a,b,ans[10000];
    char *c,*d,*e;
    int i = 0;
    c = (char*)(malloc(20 * sizeof(char)));
    d = (char*)(malloc(20 * sizeof(char)));
    scanf("%d",&n);
    while(i < n){
            scanf("%d",&a);
            scanf("%d",&b);
            itoa(a,c,10);
            itoa(b,d,10);
            a = atoi(strrev(c)) + atoi(strrev(d));
            itoa(a,c,10);
            e = c;
            while(*e == '0')e++;
            ans[i] = atoi(strrev(e));
            i++;
            }
    i = 0;
    while(i < n){
            printf("%d\n",ans[i]);
            i++;
            }
}

最佳答案

您的程序中没有声明 strrev 这样的函数。编译器假定它是某个返回 int 的未知函数。因此,诊断消息是这样的,因为 atoi 需要一个指针,而不是 int

什么是strrev?为什么你在不先声明的情况下尝试调用这个函数? C 标准库没有这样的函数,因此包含您已经包含的那些标准头文件是不够的(除非您假设一些扩展实现)。

关于c - 传递 'atoi' 的参数 1 使整数指针无需强制转换......任何人都可以帮助我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3027678/

相关文章:

C 中此 fork 概念的正确输出

c# - Python 从 c# 转换 Calculating CRC8 from 4/5 bytes frame

c - 当我们将 "cc"添加到 clobber 列表时,程序集输出中会发生什么

c - 数组值发生变化

c++ - 冰淇淋店的字符串程序(再次编辑)

c - 在 C 中使用 atoi() 解析具有二进制值的字符数组

使用atoi将char数组转换为int数组

c - 没有任何非法访问的随机段错误

c - 是否可以使用整数作为数组的名称?

ios - 迭代包含 "Extended ASCII"个字符的 const unsigned char *