Alexandros Tsos Alexandros Tsos - 13 days ago 6
C Question

i have this error: argument of type 'char' is incompatible with parameter of type char*

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#define TRUE -1
#define FALSE 0
void incaps1(char*s)
{int i;
int PreviousCharWasSpace;

for(i=0,PreviousCharWasSpace=TRUE ; i!=sizeof(*s) ; i++)
{ if (*(s+i)==' ')
PreviousCharWasSpace=TRUE;
else{
if (PreviousCharWasSpace)
{ *(s+i)=toupper(*(s+i));
PreviousCharWasSpace=FALSE;
}
}
}
printf("%s\n",*s);
}



int main(){
char phrase[256];
while(gets(phrase)){
char*s=phrase;
incaps1(*s);
}


I have an error in incpas1(s) which underlines '' and says "error:argument of type 'char' is incompatible with parameter of type char* "
}

Answer

I think you mean

incaps1( s );
        ^^^^

Take into account that this loop is wrong

for(i=0,PreviousCharWasSpace=TRUE ; i!=sizeof(*s) ; i++)
                                    ^^^^^^^^^^^^   

It seems there must be at least

for(i=0,PreviousCharWasSpace=TRUE ; i!=strlen(s) ; i++)
                                    ^^^^^^^^^^^^   

Here is also a mistake

printf("%s\n",*s);

Write instead

printf("%s\n", s);
              ^^^
Comments