So i'm having a problem with cin input :
cout << "It's your turn (you have " << tries << " tries left): ";
cin >> t;
Problem is that the user is able to input more than 1 character on the console even tho it's a "char" type.
How i can limit the cin input on the program ?
What you can do, is to validate the input and remove any remaining characters in the input stream so that they do not interfere with other cin statements. This is done via a call to cin.ignore right after the cin statement to t.
Don't have a laptop or pc. But i tried by combining all three files in on CxxDroid and there was an immediate crash. Then i saw the code, i don't know how it is working at your end.
char* mot is uninitialized
you are allocating memory for it by first calling lenght(mot), inside lenght function, the program will crash at first dereference (indexing) while(str[i]) itself.
Thanks for replies !
Well i have tried that cin.ignore but doesn't seems to work. Maybe i have the bad syntax but i can't find any good exemple on google.
You have any idea how i can syntax the cin.ignore to ignore all but the first char ?
I know right that only 1 char will be stored but well here is the project :
If you compile and try run it, once you put the word you want to find, once you input a char after you can output more than 1 char it will loop the size of all char for some reason
Actually, there isn't any way to put limit because it will continue reading input unless you hit enter key and if you entered more characters than limit (in this case is 1) then it will cause runtime error.