ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1567. SMS-spam

Compilation error ?
Posted by George 25 Oct 2011 02:29
while compiler write :
ebc95803-3963-4032-87c1-67e160a8f044
ebc95803-3963-4032-87c1-67e160a8f044(9) : error C2039: 'getline' : is not a member of 'std'
ebc95803-3963-4032-87c1-67e160a8f044(9) : error C3861: 'getline': identifier not found


#include <iostream>

using namespace std;

int main()
{
    string line;
    int sum;
    while ( getline(cin,line) )
    {
        sum=0;
        for (unsigned int i=0;i<line.length();i++)
        {
            if (line[i]!=' ')
            {
                sum=sum+(line[i]-1)%3+1;
            }
            else
            {
                sum++;
            }
        }
        cout<<sum<<"\n";
    }
}

while we can see in example...

#include <iostream>
...
// numbers
int n;
while (std::cin >> n)
{
   ...
}
// lines
std::string line;
while (std::getline(std::cin, line))
{
   ...
}
// characters
char c;
while (std::cin.get(c))
{
   ...
}

or example is wrong ?