List of all available Websheets
Viewing cpp/streams/examples/getline_eg by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Using <tt>getline(ifstream, string)</tt>. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; int main() { int i=0; while (true) { i++; string text; getline(cin, text); // buffer to write to, then buffer size if (cin.fail()) return 0; cout << "Line " << i << ", " << text.length() << " chars: "; cout << text << endl; } } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {"stdin": "first line\nsecond line\na very long long long long long long line\nanother line"} ] |
Solution visibility | |
Is example? i.e., just a demo |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.