Im trying to compare 2 values in C++ (which im new to so please go easy)
struct styles{
int itemNo;
char desc[26];
char brand[21]; //between 3 - 20
char category;
double cost;
};
struct declared above, then im using this code in another function
char cat[2];
for (x=0;x<size;x++)
{
if (strcmp(cat,styleAr[x].category)==0)
its giving me an error with the 'styleAr[x].category' in the if statement: argument of type "char" is incompatible with parameter of type "const char *
any explanations on how I could solve this would be great
You have category
as a single char
and cat
is an array of chars (i.e. a char *
)... you probably didn't mean to compare a string with a single character