View Single Post
Old 10-10-2004, 07:54 AM   #8 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
quote:
--------------------------------------------------------------------------------
yeah, i don't need someone to build me an app, i was just wondering how to code the ctrl-z part. that's the part that got me.
--------------------------------------------------------------------------------
Here's a lil surprise for your friend (and you). Run it and see what conclusions you can draw:
Code:
 #include <iostream>
#include <string>
#include <vector>

using namespace std;

//Elementary functions(s) void requestValue();

//Optional helper function(s) void wait_for_enter();

//Elementary globals.
vector<double> theVector;
double theVal;

int main()
{
   requestValue();
   
   //Process data here.
   
   wait_for_enter();
   return 0;
}

////////////////////////////////////////////////////////////// void requestValue()
{
   cout<<"Enter the value (double precision accepted) => ";
   cin>>theVal;
   while(!cin.fail() )
   {
      theVector.push_back(theVal);
      cout<<"Enter the next value => ";
      cin>>theVal;
   }
}

////////////////////////////////////////////////////////////// void wait_for_enter()
{
  cout << "press <enter> to continue...\n";
  // Reset failstate, just in case.
  cin.clear();
  string line;
  getline( cin, line);
}
Obviously requestValue() is what your friend is interested in.
__________________
Valmont is offline   Reply With Quote