Momo said:
> Can you please give some example?? I beening trying to do that, but i
> am having no idea how do i start.
> Thx for help.
See Below.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
char *RemoveLeadingWP(char *s);
char *RemoveTrailingWP(char *s);
char *ParseData(char *s);
int main(void)
{
char *result, test[64] = "PROGRAM= A string without leading "
"and trailing Whitespace ";
result = ParseData(test);
if(result)
printf("Parsed string is: \"%s\"\n",result);
return 0;
}
char *RemoveLeadingWP(char *s)
{
char *s1;
for(s1 = s; *s1 != '\0'; s1++)
if(!isspace((unsigned char)*s1)) break;
if(s1 != s) memmove(s,s1,strlen(s1)+1);
return s;
}
char *RemoveTrailingWP(char *s)
{
char *endp;
for(endp = s+strlen(s); endp!=s; endp-- )
if(!isspace((unsigned char)*(endp-1))) break;
*endp = '\0';
return s;
}
char *ParseData(char *s)
{
char *s1;
if((s1 = strrchr(s,'=')) != NULL)
{
RemoveTrailingWP(++s1);
RemoveLeadingWP(s1);
return s1;
}
return NULL;
}