string parsing

#include"stdio.h"
#include"string.h"
#include"math.h"

void main()
{
char tokens[11][3],text[]="sin(5)+cos(5)",*ptext,*ptokens=tokens[9];int i=0,j,z;
ptext=text;
for(i=0;i<11;i++)
{
for(j=0;j<3;j++)
tokens[i][j]='0';
}

if(*ptext=='s')
{
tokens[i][3]=='sin';
i++;ptext++;
}
if(*ptext=='('||*ptext==')')
{
tokens[i][3]=*ptext;
i++;ptext++;
}
if(*ptext=='c')
{
tokens[i][3]='cos';
i++;ptext++;
}
if(*ptext=='+'||*ptext=='-'||*ptext=='*'||*ptext=='/')
{
tokens[i][3]=*ptext;
i++;ptext++;
}

if(*ptext=='l')
{
tokens[i][3]='log';
i++;ptext++;
}
for(int i=0;i<11;i++)
{
tokens[i][strlen(tokens[i]+1)]='\0';



}
if(*ptext<='9'&&*ptext>='0')

{
tokens[i][3]=*ptext;
i++;ptext++;
}

do
{
printf("%s\r\n",ptokens);
ptokens++;

}

while((*ptokens));

}
this is my code for string parsing but it prints strange characters .so what is wrong in this code .and some times an error appears(stack around variable 'tokens' was corrupted).what can i do ?please any help
Last edited on
Do you have to do it in C, or can you switch to C++?
in C
any helllllllllllllp please
tokens[i][3]=='sin';

Was that meant to be

tokens[i][3]='sin';

Shouldn't those be in double-quotes anyway?
Topic archived. No new replies allowed.