为什么我的do..while不被触发呢???
我调试的是最低下的scanf没有被触发。程序代码:
#include <stdio.h> #include <stdlib.h> void input_f(char str[]) { scanf("%s",str); if(!check_f(str)) { return ; } } void change_f(char * str) { int len; lower_f(str); len = strlen_f(str); if(len >= 100) { printf("Too Long!\n"); return; } if (str[0] == 'a' || str[0] == 'e' || str[0] == 'i' || str[0] == 'o' || str[0] == 'u') { str[len++] = 'p'; str[len++] = 'y'; str[len] = '\0'; } else { int i; for( i = 1; i < len; i++ ) { str[i - 1] = str[i]; } str[i++] = 'p'; str[i++] = 'y'; str[i] = '\0'; } } void print_f(char str[]) { printf("%s",str); } void lower_char_f(char * str)//修改为小写 { if(*str < 'a') *str = *str + ('a' - 'A'); } void lower_f(char str[]) { int len; len = strlen_f(str); int i; for( i = 0; i < len; i++) { if(str[i] < 'a') str[i] = str[i] + ('a' - 'A'); } } int strlen_f(char * str)//== (char str[]) { int len,i; for( i = 0;; i++) { if(str[i] == '\0') { len = i; break; } } return len; } int check_f(char * str)//if:void check_f()? { int len,i; len = strlen_f(str); for( i = 0; str[i] != '\0'; i++) { if(str[i] < 'A' || str[i] > 'z' || str[i] > 'Z' && str[i] < 'a') { printf("ERROR\n"); return -1; } } return 1; } int main() { char str[105],flag = 'y'; do { printf("Welcome Pig(),Please input the string now!\n"); input_f(str); change_f(str); print_f(str); printf("\nDo you want again?\n"); scanf("%c",&flag); lower_char_f(&flag); } while (flag == "yes" ||flag == 'y'); return 0; }
求解~