Jump to content
  • Advertisement
Sign in to follow this  
gtgdgfdgfd

C++ console programming using cbuilder4

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem with C++ console programming using cbuilde4. I input data through overloaded operators of istream and write to a file through ofstream. Its working alright without validations. I have a problem of how to validate inputs of numeric fields and get back to the istream and write to the file. See below a part of code where I have tried this and relavent coding. If any body can help on this thats great. Thanks in advance. istream& operator>> (istream& instr, const Details& details){ details.inputData(instr); } stream& Details::inputData(istream& instr){ int keyval=0; cout << "ID Number : " << idNumber<<endl; cout << "Name : "; instr.ignore(); instr.getline(name,19); cout << "Address1 : "; instr.getline(address1,19); cout << "Address2 : "; instr.getline(address2,19); char *inputString; cout << "Postal Code : "; //validate numeric field postalCode ***************????? for (int i=0; i<8;i++){ keyval = getch(); if (keyval==13){ i=8;} cout<<(char)keyval; if(isdigit(keyval)) { inputString==(char)keyval; } } *inputString >> postalCode ; //????problem is here cout <<endl<< "City : "; instr.ignore(); instr.getline(city,19); cout << "Fax No : "; instr >> fax ; instr.ignore(); return instr; }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!