Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using wchar_t in the main function

Is it wrong to use the main function in C++ Visual Studio 2017 as following:

int main(int argc, wchar_t* argv[])

as my program can receive special characters.

like image 711
Simz Avatar asked Jun 24 '26 11:06

Simz


1 Answers

Please go and read the remarks section on GetCommandLine:

ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The main and WinMain functions cannot return Unicode strings.

Unicode console process written in C can use the wmain() or _tmain() function to access the command-line arguments. Unicode GUI applications must use the GetCommandLineW function to access Unicode strings.

To convert the command line to an argv style array of strings, call the CommandLineToArgvW function.

like image 194
Swordfish Avatar answered Jun 27 '26 00:06

Swordfish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!