0

how can i solve this?

Hey guys why I have this error in lines 22, 26, 30, and 34? error : subscribted value is neither nor pointer nor vector #include <stdio.h> void StrStat(Str); int main() { char StrReza[100]; fgets(StrReza,100,stdin); StrStat(StrReza); return 0; } void StrStat(Str) { int a; a = strlen(Str); int baseda; baseda = 0; int biseda; biseda = 0; int adad; adad = 0; for(int i=0;i<a;i++) { if(Str[i]==97 || Str[i]==101 || Str[i]==117 || Str[i]==111 || Str[i]==105 || Str[i]==65 || Str[i]==69 || Str[i]==79 || Str[i]==85 || Str[i]==73) { baseda++; } else if(Str[i]>=65 && Str[i]<=90 && Str[i]!=65 && Str[i]!=69 && Str[i]!=79 && Str[i]!=85 && Str[i]!=73) { biseda++; } else if(Str[i]>=97 && Str[i]<=122 && Str[i]!=97 && Str[i]!=101 && Str[i]!=117 && Str[i]!=111 && Str[i]!=105 ) { biseda++; } else if(Str[i]>=48 && Str[i]<=57) { adad++; } } printf("%d\n%d\n%d",baseda,biseda,adad); }

13th May 2021, 7:56 AM
reza
reza - avatar
8 Respuestas
+ 2
hey reza change following 1.include <string.h> 2.void StrStat(char []); 3.void StrStat(char*Str)
13th May 2021, 8:15 AM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
+ 1
Str is a string.... in line 21, in the if statement you are comparing string with integer....thats why its an error...
13th May 2021, 8:01 AM
Md. Mursalatul Islam Pallob
Md. Mursalatul Islam Pallob - avatar
+ 1
Thirt13n Yeah it's working now Thanks a lot
13th May 2021, 8:22 AM
reza
reza - avatar
+ 1
Calvin Thomas Counting vowels and consonants and numbers in a string
14th May 2021, 7:49 PM
reza
reza - avatar
+ 1
Here's a simple solution: #include <stdio.h> void isalpha(char k); void str_stat(char *txt); int main() { char buf[50]; fgets(buf, 50, stdin); str_stat(buf); return 0; } void isalpha(char k) { return k > 64 && k < 91 || k > 96 && k < 123; } void str_stat(char *txt) { int count_1 = 0, count_2 = 0, count_3 = 0; char vowels[] = "aeiou"; for (int i=0;txt[i];i++) { for (int j=0;j<6;j++) { if (txt[i] == vowels[j]) { count_1++; break; } count_3 += j > 4 && isalpha(txt[i]); } count_2 += txt[i] > 47 && txt[i] < 58; } printf("No. of vowels = %d\nNo. of consonants = %d\nNo. of numbers = %d", count_1, count_3, count_2); } // Hope this helps
14th May 2021, 8:06 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Calvin Thomas Yeah it's simpler Thanks It helped me
14th May 2021, 8:10 PM
reza
reza - avatar
0
@Md. Mursalatul lslam Pallob I changed it to Str[i]=='a' and like this but I have this error again.
13th May 2021, 8:09 AM
reza
reza - avatar
0
reza What should this code do?
14th May 2021, 7:45 PM
Calvin Thomas
Calvin Thomas - avatar