Learn some c++! Read my first post in this thread, and wherever you're trying to learn c++ from again.
You can't just cobble together a bunch of code snippets other people give you, you need to understand what is being done and why, and apply it.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.