Function problems

I've recently started learning C++ and after a while I decided to put something of my own together, instead of doing simple tutorials. Whilst I have dealt with most of my compilation errors and what not I have encountered an obstacle, a rather difficult obstacle(for me). So I have this one part of code that awaits for input. When the input is given the code compares given input with provided array of values. If the given value is the same as one of the array values then the value is getting deleted from the array. This is repeated to the point when array has no more elements in it. And if input is not the same as the one of the array values then it breaks and he code is restarted from beginning . So It is a simple "guess the multiple values" program. The problem is that I wanted to add time limit to this, e.g. input 5 ints, if one of them is wrong break, and if inputs are not given within x seconds break too. I thought to myself that I should use threading. But since i have just started with C++ I have no idea how to use thread lib, and reading documentation gives me a solid head ache(really, I don't understand anything). Is it possible to do this with threads? If yes then how? And are threads necessary for this?

Also, I have one more question.
I've made a simple function to put text letter by letter.
It looks like this:
1
2
3
4
5
6
7
8
9
void put_text(char* text)
{
    int length=std::char_traits<char>::length(text);
    for(int i=0; i<length; i++)
    {
        putchar(text[i]);
        std::this_thread::sleep_for(chrono::milliseconds(30));
    }
}

Now, because there is char* as an argument, this function can't do anything with integers and so on, just like cout does. How to make it work like cout?
Now, because there is char* as an argument, this function can't do anything with integers and so on, just like cout does. How to make it work like cout?
How would this function work with ints?

YOu are want either function overloading or function template depending on your answer.
For the second question, I think you could do something using stringstreams, but I'm not too familiar with them so I can't help you there. You could also save the number as a std::string and then you would be able to print it char by char.
Topic archived. No new replies allowed.