1 year ago
#384828

Ossama
String token segmentation fault in C
void infixToPostfix(char *infix)
{
char postfix[100], tokens[20][20], *temptok;
int i = 0;
temptok = strtok(infix, "+-*/() ");
tokens[i++][20] = *temptok;
while (temptok != NULL)
{
temptok = strtok(NULL, "+-*/() ");
tokens[i++][20] = *temptok;
printf("%s ", *temptok);
}
}
int main()
{
char infix[100] = "5+7+8+10*100";
/*printf("Please enter the infix expression: ");
gets(infix);*/
infixToPostfix(infix);
system("pause");
return 0;
}
This code gives me a segmentation fault when i try to tokenize my string. What am i doing wrong?
c
strtok
0 Answers
Your Answer