我正处于解决这个问题的边缘。只是看......任何人都可以告诉我应该改变什么?

时间:2015-12-13 17:11:41

标签: c

<html>
<form action="update1.php" method="post">
<input type="hidden" name="complaint" value="<?php echo $_GET['complaint'] ?>"
<input type= "text" name="blue"></input>
<input type= "submit"></input>
</form>
</html>

2 个答案:

答案 0 :(得分:3)

您无法使用switch来比较字符串。它仅适用于整数类型。此外,字符串常量用双引号(")表示,而不是单引号(')。您需要使用strcmp来比较字符串:

if (!strcmp(name, "name1")) {
    printf("\nYou are good\n");
} else if (!strcmp(name, "name2")) {
    printf("\nYou are not so good\n");
} else if (!strcmp(name, "name3")) {
    printf("\nYou are bad\n");
} else if (!strcmp(name, "name4")) {
    printf("\nYou are very ba\n");
} else {
    printf("\nYou entered an invalid letter\n");
}

答案 1 :(得分:1)

switch(expression)

switch语句中使用的expression必须具有整数或枚举类型,或者是类类型,其中类具有单个转换函数为整数或枚举类型。

您不能使用switch来比较两个字符串,因为 dbush 表示。比较两个字符串并打印所需的结果会更好。

您还应该删除尾随的换行符,否则您将无法获得所需的结果:

fgets(name,20,stdin);
len = strlen(name);
name[len - 1] = '\0';