Home > Back-end >  The C language
The C language

Time:10-04

Vc + + 6.0 now I enter a number, for example, carriage return has according to, and found that the input number is wrong, it should be another number, that how returns this step input number, because once the input data have mistake will open program feel good trouble, is there a good way to solve this problem

CodePudding user response:

In fact this is the problem that a user experience
To change the program control logic
Add one line of output, prompt the user, what is it you just input, if confirmed, will continue to other, otherwise it returns to enter
Problem is to do so when you input is right, but also one by one test, will feel very troublesome

A balanced approach, input data, you want to keep in the file is in the center, let the program to read from the file
To the inside of the file content is change, changed again you can save after confirmation, and then to run the program, to avoid this problem

CodePudding user response:

There is also a skill complement, after all read to write files to open and read from the file operations, such as to change the code
The following skills, don't have to change a code, that is using the Windows command line pipe capacity
Windows command line, you can use alternative keyboard input file
CMD, such as your exe is 1. Exe
So 1. Exe & lt; A.t xt
Can make a.t of xt content as the content of the keyboard input to 1. Exe files to
This program code without change, by editing the 1. TXT to fix you repeated use of the input
  • Related