c - 53 :6: warning: conflicting types for function

标签 c

#include <stdio.h>
#include <string.h>
struct students{
    char name[50];
    int age;
    int height;
};

int main(int argc, char **argv)
{
    struct students manoj;

    strcpy(manoj.name, "manojkumar");
    manoj.age = 15;

    displaymanoj(&manoj); //print testing \n , name , age 

    return 0;
}

void displaymanoj(struct students *ptr) {
    printf("Testing...............DEBUG\n");
    printf("%s\t%d\n", ptr->name,ptr->age);
    printf("END OF TEST: SUCESS -manoj-");
}

我正在学习 C,它正在使用指针指向结构变量。当我运行程序时,我得到了正确的输出。只是我的 Geany IDE 给出了一些消息,我想知道为什么。

我的编译器消息如下:

最佳答案

您必须在调用它们之前声明这些函数。

所以你的程序应该是这样的

// Includes
// Structure

// Function prototype declaration
// This was what you were missing before
void displaymanoj(struct students *ptr);

int main(int argc, char **argv)
{
    ...
}

void displaymanoj(struct students *ptr) {
    ...
}

关于c - 53 :6: warning: conflicting types for function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38951881/

相关文章:

开罗分割图像

python - 获取指定函数中调用的所有函数

python - 如何从Python中的二进制文件解析序列化的C结构?

c - C中的结构排列

java - 我应该如何订购 if 语句?

c - 如何知道线程内存使用情况?

C - 检查是否分配了 Integer

c - 使用ASLR获取随机匿名映射地址

c - 我的插入代码在 c 中无法正常工作

c++ - 使用 Opencv 绘制彩色图像的直方图