Skip to content

Instantly share code, notes, and snippets.

@nootanghimire
Created April 7, 2014 17:01
Show Gist options
  • Save nootanghimire/10024161 to your computer and use it in GitHub Desktop.
Save nootanghimire/10024161 to your computer and use it in GitHub Desktop.
Dynamically Get String without using cin.get()
#include <iostream>
#include <string>
using namespace std;
int main()
{
std::string s;
//s = new char[200];
int counter = 0;
std::cin >> std::noskipws; //don't skip whitespaces
char c;
cin >> s;
while (std::cin >> c)
{
if(c == '\n' || c == '\r')
break;
s.push_back(c);
}
cout<<s;
cout<<endl;
return 0;
}
@rhoit
Copy link

rhoit commented Apr 8, 2014

के गरेको यसमा?

@nootanghimire
Copy link
Author

@rhoit dai: save as you type (kindof) 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment