Echo Program

Hey Could Any One please tell me how to write an echo program in c++
example: if user enter "hey how are you 123" then output same show
Here you go:

1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <string>

int main(){

    std::string echo;
    std::getline(cin,echo);
    std::cout << echo;

}
I'm sure you can find one using Google somewhere.

We can only help you to do or understand stuff, we don't do homework.
Another shorter example:
1
2
3
4
5
6
#include <iostream>

int main()
{
    std::cout << std::cin.rdbuf();
}
Good luck trying to find why it works.
i did`t understand the line std::cin.rdbuf();
please explain
Topic archived. No new replies allowed.