For this to work, you'll have to save the number of characters matched in each retrieval... Something like below.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char**argv)
{
int res = 0;
int res2 = 0;
char buf [] = "25+2;44+1;8-2.";
char op1[20];
char op2[20];
char operazione[20];
char en[20];
res = sscanf(&buf[res2],"%[0-9] %[+-] %[0-9] %[;.]",op1,operazione,op2,en );
res2 += res + 1;
fprintf(stdout, "op1->%s, op2->%s, operazione->%s, en->%s\n", op1, op2, operazione, en);
res = sscanf(&buf[res2],"%[0-9] %[+-] %[0-9] %[;.]",op1,operazione,op2,en );
res2 += res + 1;
fprintf(stdout, "op1->%s, op2->%s, operazione->%s, en->%s\n", op1, op2, operazione, en);
res = sscanf(&buf[res2],"%[0-9] %[+-] %[0-9] %[;.]",op1,operazione,op2,en );
fprintf(stdout, "op1->%s, op2->%s, operazione->%s, en->%s\n", op1, op2, operazione, en);
exit(EXIT_SUCCESS);
}
I would put this functionality in a while loop to clean it up.
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387