Q:

A function in C++ made being skipped?

I have made a function called pause(). Here is the code for it:
void pause(){
    std::cin.sync();
    std::cin.ignore();
}

I also use a declaration in front of my code:
void pause();

int main(){

}

It worked at first, but now for some reason it just skips the function when I call it...
std::cout << "Random text. Press any key to carry on...";
pause();

EDIT: Unfortunately, when I try it differently, it goes makes me enter something and then I have to press enter. Is there really not a way to make it so that if you press any key (like the ugly system("pause") it immediately carries on? I'll have to make a new thread for this...

A:

This is why it's important to post the smallest complete code you can come up with that compiles and runs and shows the problem. Chances are, though, that there's some input done before calling this function, and it's leaving something in the input buffer. So pause isn't being skipped, but it returns immediately because of the noise in the input.

