Here's a quote from the C standard draft, n1570.pdf:
5.1.2.2.1 Program startup
1 The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;10) or in some other implementation-defined manner.
10) Thus, int can be replaced by a typedef name defined as int, or the type of argv can be written as char ** argv, and so on.
This should be fairly simple to comprehend. If your implementation supports argv
with the type wchar_t**
, then it'll work on your implementation in an implementation-defined manner. If you require portability, don't rely on anything implementation-defined.
Additionally, wcslen()
is declared to return a size_t
value, which you ought to use with the %zu
directive to print, and it's probably also a good idea to #include <wchar.h>
.
I don't think either of these caused your issue, but they both cause undefined behavior nonetheless.