我一直在尝试练习使用参数和函数,但在这个基本尝试中我不断收到“参数太少错误”。谁能向我指出我需要做什么才能编译它?
#include <stdio.h>
#include <stdlib.h>
int peachy(char* str, int a, int b)
{
str = "g";
a = 7;
b = 6;
printf("Character: %s\n", str);
printf("First Integer: %d\n", a);
printf("Second Integer: %d\n", b);
}
int main(void)
{
peachy();
}
最佳答案
像这样
#include <stdio.h>
#include <stdlib.h>
void peachy(char* str, int a, int b)
{
printf("Character: %s\n", str);
printf("First Integer: %d\n", a);
printf("Second Integer: %d\n", b);
}
int main(void)
{
peachy("g", 7, 6);
peachy("foo", 42, 43); //just to show the use of function args
}
关于c - 函数 ‘peachy’ 的参数太少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53182191/