当我运行这个程序时,它会打印问题并从用户那里得到答案,但它没有说明它是对还是错。请帮忙!
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
void
correct (char str[])
{
char c1 = "Cristoforo";
char c2 = "cristoforo";
char c3 = "CRISTOFORO";
int conf = strcmp (str, c1);
int conf1 = strcmp (str, c2);
int conf2 = strcmp (str, c3);
if (conf1 == 0 || conf == 0 || conf2 == 0)
{
printf ("The answer is correct");
}
else
{
printf ("The answer is wrong");
}
}
int
main ()
{
char s[] = "What's the name of the explorere Colombus?\n";
char r[100];
printf ("%s", s);
gets (r);
void correct (r);
}
答案 0 :(得分:0)
void correct(r)
是声明,它的意思是 - 正确的是一个函数,它在参数中接受 r 类型并返回 void。只需删除 void
即可调用函数。 correct(r)
。并且您需要将 char
更改为 char *
或 const char*
。
const char *c1 = "Cristoforo";
const char *c2 = "cristoforo";
const char *c3 = "CRISTOFORO";
答案 1 :(得分:0)
由于 seg
的错误使用,您遇到了 strcmp()
错误。第二个参数必须是 const char *__s2
。那么正确的是:
int conf = strcmp(str, "Cristoforo");
int conf1 = strcmp(str, "cristoforo");
int conf2 = strcmp(str, "CRISTOFORO");
并在调用 void
correct(r)