Questions tagged [stringstream]

stringstream provides an interface to manipulate strings as if they were input/output streams.

The objects of this class maintain internally a pointer to a stringbuf object that can be obtained/modified by calling member rdbuf. This streambuf-derived object controls a sequence of characters (string) that can be obtained/modified by calling member str.

1178 questions
-4
votes
2 answers

Trying to get user input and cout a message expect when I enter a valid name it couts all of them

#include #include #include using namespace std; int main() { string gun = ""; cout << "Enter The Gun You Would Like To Know The Type Of Ammo For: \n"; getline(cin, gun); if (gun == "b95" || "B95" ||…
-4
votes
2 answers

C++: Converting stringstream to char* runtime error

I am trying to convert in C++ a stringstream of "1.txt" so that it is equal to a char* value of "1.txt". I need the raw char* as an argument for a function, so it can't be const char or anything else. When I run it, I get a blank output. Why, and…
Eric Morse
  • 7
  • 1
  • 3
-4
votes
1 answer

Stringstream is not recognized in while loop

Set2 while loop does not populate for some reason. Set1 works just fine. std::stringstream ss; std::string line; std::getline(infile, line); ss.str(line); int input; // Populate set1 while(ss >> input) { set1.insert(input); std::cout <<…
-5
votes
1 answer

std::stringstream object unrecognized in std::to_string replacement function

Since std::to_string doesn't work for me, and since I'm working on a very difficult environment at the moment (I'm working on Android using a Linux terminal emulator), I've decided to leave it broken and use a user-made function instead to replace…
user6245072
  • 2,051
  • 21
  • 34
-5
votes
2 answers

Why is the modulus operator giving wrong answer?

#include #include #include using namespace std; int main(){ stringstream ss; ss << 32; string str = ss.str(); cout << str << endl << str[0] << endl << str[1] <
vatsal
  • 109
  • 2
  • 12
-5
votes
1 answer

Save one by one words from string to the list

I want to get words from a string (like this: "My name is Jonathan") one by one, and save each word into an elemnt on a list. I want to do it extremelly simple, without any vectors etc. For example I take one word from a string and save it into an…
Wojtek Smol
  • 57
  • 1
  • 2
1 2 3
78
79