‌experssion must have a class type | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

‌experssion must have a class type

char a[100]; for(int i=0; i<a.length; i++) in (a.length) it gives "experssion must have a class type"error what it means and how can i solve it?

19th Dec 2016, 4:38 PM
Matin Grimes
Matin Grimes - avatar
6 Answers
+ 3
my bad...that's C# syntax I wrote.
19th Dec 2016, 5:06 PM
HAL8999++;
HAL8999++; - avatar
+ 2
try this instead: char[] a = new char [100];
19th Dec 2016, 4:52 PM
HAL8999++;
HAL8999++; - avatar
+ 1
Hi bro how can i use strlen for array? it's only for strings i think, am i right?
19th Dec 2016, 5:10 PM
Matin Grimes
Matin Grimes - avatar
0
i tried it It didnt work
19th Dec 2016, 4:59 PM
Matin Grimes
Matin Grimes - avatar
0
hey matin, use strlen function intstead of length. use strlen(a), it will work. also add this line before main function #include <string.h>
19th Dec 2016, 5:05 PM
Ravi Kumar
Ravi Kumar - avatar
0
yes you can, because String is actually the array of characters. :)
19th Dec 2016, 5:43 PM
Ravi Kumar
Ravi Kumar - avatar