Getting the value and the string from 1 line

Hi, so i have a file that contains a integer and some letters in one line,
e.g 123hello
i want to read the integer '123' and 'hello' separately and assign them to a variable.

i have tried getline() but i could only read the integer part. :S

some help please! thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <sstream>

int main ()
{
    std::string str;
    int temp;
    std::string oh;
    
    std::getline(std::cin, str);
    std::stringstream mystr(str);
    
    if ((mystr >> temp) && (mystr >> oh))
        std::cout << temp << " " << oh <<std::endl;
    
    return 0;
}
Topic archived. No new replies allowed.