Z
Z
ZhukovMisha2019-06-27 14:27:05
Command line
ZhukovMisha, 2019-06-27 14:27:05

How to count the whole line except the first character in the console?

How to read the entire line except for the first character in the console, or how to read the entire line into an array
How to read from the console, and not from a file

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2019-06-27
@ZhukovMisha

How to count the whole string except the first character

#include<iostream>
#include<algorithm>
#include<iterator>
#include<string>
using namespace std;

string getOneStr(istream& is)
{
  string result;
  copy(++istreambuf_iterator<char>(is), {}, back_inserter(result));
  return result;
}

int main()
{
  cout << "Enter the line (Win Ctrl+Z or Lin Ctrl+D end)\n$: ";
  string s = getOneStr(cin);
  cout << s << endl;
}

T
tsarevfs, 2019-06-27
@tsarevfs

https://ru.cppreference.com/w/cpp/string/basic_str...
https://ru.cppreference.com/w/cpp/string/basic_str...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question