Created
April 7, 2014 17:01
-
-
Save nootanghimire/10024161 to your computer and use it in GitHub Desktop.
Dynamically Get String without using cin.get()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
के गरेको यसमा?