Jump to content
  • Advertisement
Sign in to follow this  

C++ console programming using cbuilder4

This topic is 5100 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
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!