: In function ‘main’:
04.c:10:12: error: ‘str’ undeclared (first use in this function)
check2(str);
^
04.c:10:12: note: each undeclared identifier is reported only once for each function it appears in
04.c: In function ‘check2’:
04.c:54:16: warning: passing argument 1 of ‘strcmp’ makes pointer from integer without a cast [-Wint-conversion]
while(strcmp(str,str2)!=0);
^
In file included from 04.c:3:0:
/usr/include/string.h:140:12: note: expected ‘const char *’ but argument is of type ‘char’
extern int strcmp (const char *__s1, const char *__s2)
コード #include<stdio.h> #include<ctype.h> #include<string.h> int check(void); int check2(char str); int main(void){ int checker=check(); if(checker==0){ printf("入力は適切です\n"); check2(str); } if(checker==1){ printf("入力が不適切です。大文字は使用できません。\n"); } if(checker==2){ printf("入力が不適切です。使用できる文字は英数字のみです。\n"); } return 0; } int check(void){ char str[30]; int i; printf("英小文字および数字を使った文字列を入力してください:"); scanf("%s",str); for(i=0;str[i]!='\0';i++){ if(islower(str[i]) || isdigit(str[i])){ return 0; } else{ if(isupper(str[i]) || isdigit(str[i])){ return 1; } else { return 2; } } } } int check2(char str){ char str2[30]; int j; printf("再度同じ文字列を入力してください:"); do{ scanf("%s",str2); for(j=0;str2[j]!='\0';j++){ if(isupper(str2[j])!=0){ str2[j]=tolower(str2[j]); }}} while(strcmp(str,str2)!=0); printf("文字列が一致しました\n"); return 0; }
回答3件
あなたの回答
tips
プレビュー