Jump to content
  • Advertisement

gtgdgfdgfd

Member
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

122 Neutral

About gtgdgfdgfd

  • Rank
    Newbie
  1. 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; }
  • 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!