Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementing an user interface based on text commands in C++
    text
    copied!<p>For long while now I have been struggling with creating the input method for my program.</p> <p>I want the program to accept input in forms like this:</p> <pre><code>function entity(number,text,text) function entity(number) function entity(int, text, int) </code></pre> <p>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.</p> <p>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</p> <pre><code>string function, entity; char values[1024]; char command[1024]; cin.getline(command, 1024); stringstream t; t &lt;&lt; command; int number[5]; char parameter1[20]; char parameter2[20]; t &gt;&gt; funtion &gt;&gt; entity &gt;&gt; values; sscanf_s(values, "%s %s %s ", number, _countof(number), parameter1, _countof(parameter1), parameter2, _countof(parameter2)); </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload