I have a program developed by MFC C++ x86. This MFC application supports Command Line startup and obtains execution parameters through the command line. Now I want to obtain input parameters in the following way:
C:\MFCCommandLine.exe -a
C:\Input parameters:
C:\*** *** ***
Then, I want to use _getch() to get input and use putchar to replace it.
std::cout << "Input parameters: " << endl;
char str[15] = { 0 };
char ch;
for (int i = 0; (i < 14 ) && (( ch = _getch()) != EOF) && (ch != '\n'); i++)
{
str[i] = ch;
putchar('*');
}
But after testing, problems were found: After "Input Parameters: " displaying, if you don’t press Enter key, the entered character will not be changed to ; If you press Enter key and enter multiple characters, only the first character becomes , and the rest remain in plain text; The same code does not have the problem in the Windows Console application.
Maybe my writing above is wrong, I hope to obtain the input characters of the command line in MFC, and use * as a replacement to display on the command line.
Any suggestions?