I am trying not to use isSpace function so the only thing came to mind is strcpy but I am getting an error
while ( walker > 0 && strcmp(a[walker - 1],space_const) )
Warning 86: argument 1 conflicts with formal definition
Anyone know how to fix this issue? space_const is a char initialized as " "
char* strTrim(char* string)
{
char* a= string;
char delims[3];
char space_const[] =" ";
char syntax_const[]=" \t\n\v";
size_t walker = strlen ( a );
strcpy(delims,space_const);
/* Trim trailing spaces */
while ( walker > 0 && strcmp(a[walker - 1],space_const) )
--walker;
a[walker] = '\0';
/* Trim leading spaces */
walker = strspn ( a,syntax_const);
memmove ( a, a + walker, strlen ( a + walker ) + 1 );
return extractCmd(a ,space_const );
}
You are trying to compare a character (small integer) and a string.
strcmplooks like thisIt’s likely you want something like:
You should write a function. but then you would end up rewriting
isspace.Why can’t you use
isspacein the first place ?