i have an expression in an array, i want the expression to omit space and tab characters and put it into an buffer,but i dont know how to go on to do it.
Code:
#include <string.h>
char * InitExpression(char *pExpression, char *pBuf)
{
char *p = NULL;
int i = 0;
pExpression = (char *)malloc(1);
p = pExpression;
while ('\0' != *pBuf)
{
if (32 != *pBuf && 9 != *p)
{
*p = *pBuf;
p = (char *)realloc(pExpression, 1);
++p;
}
++pBuf;
}
return pExpression;
}
int main()
{
struct Polyn *pUnitaryPolynomial = NULL;
char cExpression[] = {" 95 x ^ 2 - 4 x + 2 "};
char *szExpression = NULL;
szExpression = InitExpression(szExpression, cExpression);
return 0;
}