Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. case 1:
  2.  
  3. vid_infile.open("Video.txt");
  4.  
  5. Video* NewVideo;
  6. cout<<"\tPlease enter details of Video to be added: "<<endl;
  7. cin.getline(buffer,100);
  8. cout<<"\tEnter Title: ";
  9. cin.getline(buffer,100);
  10. vidtitle = buffer;
  11.  
  12. cout<<"\tEnter Producer: ";
  13. cin.getline(buffer,100);
  14. producer = buffer;
  15.  
  16. cout<<"\tProduction Year: ";
  17. cin>>prodyear;
  18.  
  19. cout<<"\t Video ID: ";
  20. cin>>id;
  21.  
  22. cout<<"\tEnter Stock: ";
  23. cin >> keyEntered;
  24. vidstock = validateStockInput(keyEntered);
  25.  
  26.  
  27. int validateStockInput(char input) //validate input on menu selection (integer required)
  28. {
  29. char keyEntered = '1';
  30. const char *charPtr = &keyEntered;
  31. char *remainderPtr;
  32.  
  33. int stock;
  34.  
  35. keyEntered = input;
  36.  
  37. /*Error handling on menu selection input*/
  38. while(!isdigit(keyEntered)) //while key entered is an alpha character
  39. {
  40. cerr<<"\n\tInvalid Input! You entered a non-integer."<<endl;
  41. cout<<"\n\tPlease enter an INTEGER for stock amount:";
  42. cin>>keyEntered;
  43. }
  44. stock = strtol(charPtr,&remainderPtr, 0); // convert char to int
  45. return stock;
  46.  
  47. } //end validateMenuInput;
Add Comment
Please, Sign In to add comment