Posted: Mon Oct 03, 2005 9:20 pm Post subject: (No subject)
Do not use std::string::getline, atof, and character arrays. These make your program very brittle, since they do a poor job of dealing with input that's not exactly what you expect.
Thus we use a std::string which is not limited to 99 characters, as the character array is.
Just as we use the std::cin stream to get input from the keyboard, we can use a stringstream to get input from a string with equal power.
c++:
#include <iostream> #include <sstream>
int main () {
std::string buffer;
std::stringstream input_stream;
float price;
int quantity;