编译main.c时出错
错误显示:
functions.c:27:6: warning: conflicting types for 'secondfunction' [enabled by default]
functions.c:23:2: note previous implicit declaration of 'secondfunction' was here
(我的程序有一个名为main.c、header.h和functions.c的文件)
主要c:
#include "header.h" /*Includes the header file*/
int main(void) /*Starts the main function.*/
{
course();
firstfunction(filename,fileextension,fp,MAX_SIZE);
/*
thirdfunction();
fourthfunction();
fifthfunction();
sixthfunction();
*/
return 0;
} /*Ends the main function.*/
页眉.h:
#include <stdio.h>
#include <string.h>
#include "functions.c"
#define MAX_SIZE 50
struct records
{
double euid;
char firstname[MAX_SIZE];
char lastname[MAX_SIZE];
float gpa;
};
void course(void);
void firstfunction(char filename[],char fileextension[],FILE* fp,int SIZE);
void secondfunction(FILE* fp);
struct records people;
FILE* fp;
char filename[MAX_SIZE],fileextension[MAX_SIZE];
功能c:
void course(void)
{
printf("\n\n\n\n\nDepartment: CSCE\nCourse number: 1030\nProgram number: Homework 3\nName: xxxxxxxxxxxxxx\nEUID: xxxxxxxxxxxxx\nEmail: xxxxxxxxx\n\n\n\n\n");
}
void firstfunction(char filename[],char fileextension[],FILE* fp,int SIZE)
{
printf("Please enter the file name (ex:filename)\n"); /*Asks for the name and the extension*/
scanf("%s",filename);
printf("Please enter the file extension (ex:.txt)\n");
scanf("%s",fileextension);
strcat(filename,fileextension); /*Puts them together with strcat*/
printf("%s\n",filename);
fp=fopen(filename,"r");
secondfunction(fp);
fclose(fp);
} /*End of the first function*/
void secondfunction(FILE* fp)
{
} /*End of the second function.*/
谢谢你们的帮助!!
我不认为变量被传递给函数,我认为我是从函数内部调用函数。我该怎么解决?
最佳答案
从header.h中删除此行#include "functions.c"
,并在functions.c中包含header.h
关于c - C编程:警告:类型冲突?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20013004/