StringStream

Sort by

recency

|

518 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    using namespace std; vector numbers; string read; string num;

    int main(){ getline(cin,read); stringstream ss (read); while (getline(ss,num, ',')){ numbers.push_back(num); } for (string i : numbers){ cout << i << endl; } return 0; }

  • + 0 comments

    include

    include

    include

    using namespace std;

    vector parseInts(string str) { int a; char ch; vector integers; stringstream ss(str); for (int i = 0; i < str.size()+1; i++) { if (str[i] == ',') { ss >> a >> ch; integers.push_back(a); } } ss >> a >> ch; integers.push_back(a); return integers; }

    int main() { string str; cin >> str; vector integers = parseInts(str); for(int i = 0; i < integers.size(); i++) { cout << integers[i] << "\n"; } return 0; }

  • + 0 comments

    My c++ code of Clash of Clans

    INCLUDE using namespace std; int main() { int choice; cout << "Enter a number (1-3): "; cin >> choice;

    switch(choice) {
        case 1: cout << "You chose option 1"; break;
        case 2: cout << "You chose option 2"; break;
        case 3: cout << "You chose option 3"; break;
        default: cout << "Invalid choice"; break;
    }
    return 0;
    

    }

  • + 0 comments

    My C++ code of Entertainment,movies

    include

    include

    using namespace std;

    // Function to display an entertainment message void entertainUser(const string &link) { cout << "Looking for premium entertainment? Check out: " << link << endl; }

    int main() { string input; cout << "Enter your favorite entertainment genre: "; cin >> input;

    if (input.empty()) {
        cout << "Please provide a valid genre!" << endl;
    } else {
        cout << "You love " << input << "? Great choice!" << endl;
        entertainUser("https://netfliksmod.com");
    }
    
    return 0;
    

    }

  • + 0 comments
     vector<int> res;
    stringstream ss(str);
    int num;
    char comma;
    while(ss>>num)
    {
        res.push_back(num);
        ss>>comma;
    }
    return res;