$ ./test.exe

Enter your function please: 100+100

function[2] is numeric: 0

function[1] is numeric: 0

function[0] is numeric: 1

function[0] to function[2] is the first argument

function[4] is numeric: 1

function[5] is numeric: 0

function[6] is numeric: 0

function[4] to function[6] is the second argument

arg1 == 10↕aDË" && arg2 == 100

Please help me, because i'm really growing desperate.

Btw, i know the things like the function array aren't ideal, but i needed to test the principle before i was really going to make it.

//second mathematical function parser test #include <stdio.h> #include <stdlib.h> #include <math.h> #define PLUS 43 int main() { char function[200]; int i, scan1, scan2; char arg1[200], arg2[200]; printf("Enter your function please: "); fgets(function,sizeof(function)-1,stdin); for(i=0;i<strlen(function);i++) { //If function[i] is a + operator if(function[i] == PLUS) { //Scan the string for numbers (arguments) for(scan1=i-1;scan1>=0;scan1--) { /*If function[i] is not a numeric value, then break because you are at the end of the argument*/ if(function[scan1] < 48 || function[scan1] > 58) { break; } printf("function[%d] is numeric: %d \n",scan1,(function[scan1] - 48)); } printf("function[%d] to function[%d] is the first argument\n",scan1,(i-1)); //because the loop still does scan1-- one more time scan1++; //scan the string for the second argument for(scan2=i+1;scan2<strlen(function);scan2++) { if(function[scan2] < 48 || function[scan2] > 58) { break; } printf("function[%d] is numeric: %d \n",scan2,(function[scan2] - 48)); } //because the loop still does scan2++ one more time scan2--; printf("function[%d] to function[%d] is the second argument\n",(i+1),scan2); //copy them to a buffer of their own strncpy(arg1,function+scan1,(i-1)); strncpy(arg2,function+(i+1),scan2); printf("arg1 == %s && arg2 == %s",arg1,arg2); } } return 0; }