For long while now I have been struggling with creating the input method for my program.
I want the program to accept input in forms like this:
function entity(number,text,text)
function entity(number)
function entity(int, text, int)
I want the program to operate based on the commands inputted by the user in the form shown above. They chose the function e.g. add entity e.g. students and fill the data about those entities in the brackets. Now what I want to achieve is split up this string into chunks for add/entity and all values in the brackets so I can the operate based on them.
What I managed to achieve until now is completely wrong and since I am fairly new to the whole c++ thing it does make it awfully difficult to figure it all out in semi decent amount of time
string function, entity;
char values[1024];
char command[1024];
cin.getline(command, 1024);
stringstream t;
t << command;
int number[5];
char parameter1[20];
char parameter2[20];
t >> funtion >> entity >> values;
sscanf_s(values, "%s %s %s ", number, _countof(number), parameter1, _countof(parameter1), parameter2, _countof(parameter2));
In simple words I want to cut the string/char (I tried different things with both of those) from function entity(parameter,parameter,parameter) into small chunks that I can use elsewhere in my program. Need to get rid of brackets, commas and take each word separately.