i was wondering if you can take in 2 different inputs separated by a space only if there are 2 words for example if i type "word 50"
it will take in word and the number 50
but if i type just"word" it will just take in word and ignore looking for the second input
But there are other methods as well. In what context are you talking? What are you trying to do? Have any code we can look at? What exactly is the problem or solution you are trying to solve/code for?
ill lay it out for you the actual code is confusing to just pick out what it is revolving around.
i have aclass Command which has for example a help function and the function will only be called if "/help" is typed.
there are also "/addSTR" and etc function that require a number input
for example must be called like this in the console /addSTR 123
in the main
at the moment the program is asking "what class do you want to be?" you can only type in warrior; then it will show the current stats of the warrior.
i want to be able to type for example "warrior" to answer the question or type a command like /addSTR 123 but if i type just "warrior" it will only take the word warrior and not go looking for a second word or number
i have tried scanf("%s %d",&input,&value); but when i type in warrior the first time it looks for a second input
Yup, getline is your function then. You can read an entire line into a string then use string functions, or your own, to compare the string to your commands and execute the proper ones. Or if you want to use string objects you can use it's getline function. Here is the reference for that: