// This application demonstrates how to use a stringstream object to read // individual "words" or tokens from a string // It also deomonstrates Standard C vs C++ Standard header file directives #define _USE_MATH_DEFINES #include // old C-style header from Standard C Library //#include // new C++ style header from C++ Standard Library #include // only in C++ Standard Library #include #include #include using namespace std; int main(int argc, char* argv[] ) { string userInput; // user input from keyboard cout << "enter a string" << endl; getline(cin, userInput ); istringstream instr(userInput); // a stream object used to read the input string string substring; // substring of user input do { // iterate through the user input string instr >> substring; // get a word from the user input string cout << substring; isalpha( substring[1] ); } while(!instr.eof() ); // repeat until end of string float x = -M_PI; // from math.h or cmath; must #define _USE_MATH_DEFINES for M_PI x = fabs(x); // from math.h or cmath return EXIT_SUCCESS; }