您好,我正在练习我的 C 语言知识我正在尝试制作一个简单的计算器,但我遇到了这个警告Implicit Declaration of Function
,但我调用的函数已被执行。我试图用这个修复它,void start();
但该功能没有执行。
成功执行了该功能start();
,但有一个隐含的警告:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void addition()
{
int vala, valb, resu;
system("cls");
printf("SiMPLE CALCULATOR 1.0a\n");
printf("ADDITION\n");
printf("\n");
printf("Enter the first value of addend: ");
scanf("%d", &vala);
printf("Enter the second value of addend: ");
scanf("%d", &valb);
resu=vala+valb;
printf("The sum of %d and %d is: %d\n", vala, valb, resu);
printf("PRESS [ANY KEY] TO CONTINUE...");
getch();
start(); \\THIS CODE
}
void start()
{
char ope;
system("cls");
printf("SiMPLE CALCULATOR 1.0a\n");
printf("What operation will be used:");
scanf("%s", &ope);
if (ope == 'a')
{
addition();
}
else if (ope == 'b')
{
printf("bbbbbbbbbbbb\n");
}
else
{
printf("ccccccccccc\n");
}
}
int main()
{
int choices;
printf("SiMPLE CALCULATOR 1.0a\n");
printf("choose an option:");
scanf("%d", &choices);
if (choices == 1)
{
start();
}
getch();
return 0;
}
无法执行函数void start();
启动但没有隐式警告:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void addition()
{
int vala, valb, resu;
system("cls");
printf("SiMPLE CALCULATOR 1.0a\n");
printf("ADDITION\n");
printf("\n");
printf("Enter the first value of addend: ");
scanf("%d", &vala);
printf("Enter the second value of addend: ");
scanf("%d", &valb);
resu=vala+valb;
printf("The sum of %d and %d is: %d\n", vala, valb, resu);
printf("PRESS [ANY KEY] TO CONTINUE...");
getch();
void start(); \\THIS CODE
}
void start()
{
char ope;
system("cls");
printf("SiMPLE CALCULATOR 1.0a\n");
printf("What operation will be used:");
scanf("%s", &ope);
if (ope == 'a')
{
addition();
}
else if (ope == 'b')
{
printf("bbbbbbbbbbbb\n");
}
else
{
printf("ccccccccccc\n");
}
}
int main()
{
int choices;
printf("SiMPLE CALCULATOR 1.0a\n");
printf("choose an option:");
scanf("%d", &choices);
if (choices == 1)
{
start();
}
getch();
return 0;
}