I’m trying to create a game that involves the “computer” typing to you. I’m having trouble getting the typing effect instead of having the output automatically appear. If anyone has any suggestions to achieve this I’m open to ideas since I’m pretty novice at C++.
So I’m trying to get a random number to generate within the sleep method which is shown as:
Sleep(rand()%1500);
Pretty simple. Maybe too simple haha. But I’m getting the error: “expression must have arithmetic or enum type.”
My idea to achieve the typing effect is to loop each character of the output plus this sleep method until there is no more output left. This is shown as:
for(int i = 0; i <= output.length(); i++){
cout << output[i] + Sleep(random);
}
Thanks for any help!!!
This doesn’t make sense —
Sleep()has no (meaningful?) return value, and it doesn’t make any sense to add the result to your output.Break it up into two independent statements:
and you should be fine.