Thank you, Markallen85, that gave me some idea what I need to do.
To be more specific, this is the problem I have: <number><operator><number>... where number can be any number and opeartor is either +, -, / or *. I want to separate the number and the opeartors, and this is the code I have so far:
Code:
#include <stdio.h>
#include <string.h>
#define BUFFER 1024
int main() {
int loop = 1, len, i;
char seq[BUFFER];
char *token;
while(loop == 1) {
printf(": ");
/* gets the line */
fgets(seq, sizeof(seq), stdin);
/* gets the length of the string */
len = strlen(seq);
token = strtok(seq,"+");
for(i=0; token != NULL; ++i) {
printf("%s",token);
token=strtok(NULL,",");
}
...
Some questions: what type should 'token' be (I use both chars and integers/floats)? Does it have to be a pointer? Is it possble to pre-define the operators? I tried with #define OPS + - / * and put OPS where the "+" is now. I got errors like: error: parse error before ')' token
I'm confused.