| re: when i compile the cpp file(cmdargs.cpp) int main(int argc, wchar_t* argv[])
Vinu wrote:
[color=blue]
> Hai
> when i compile the cpp file(cmdargs.cpp) i attached the output below
> the program
>
> int main(int argc, wchar_t* argv[])
> {
>
> std::wcout<<L"Name of the Program is
> "<<*argv[0]<<std::endl;
> std::wcout<<L" Argument Count "<<argc-1<<std::endl;
> for(int args=1;args<argc;args++)
> {
> std::wcout<<L"Argument "<<args<<" is "<<
> *(argv[args])<<std::endl;
> }
> return 0;
> }
>
>
> output :
> ~~~~~~~~~~~~~~
> Name of the Program is
>
> -->
>
> -->
>
> -->
>
> -->
>
> #include<iostream>
> #include <stdlib.h>
> int main(int argc, wchar_t* argv[])[/color]
Does your implementation support that signature for main? Standard C++
guarantees only
int main()
and
int main(int argc, char* argv[])
.. Any other variants would be implementation-defined.
[color=blue]
> {
> std::cout<<"Name of the Program is
> "<<*argv[0]<<std::endl;[/color]
If you use wide characters, use a wide stream. And *argv[0] is a single
character.
[color=blue]
> std::cout<<" Argument Count "<<argc-1<<std::endl;
> for(int args=1;args<argc;args++)
> {
> std::cout<<"Argument "<<args<<" is "<<
> *(argv[args])<<std::endl;
> }
> return 0;
> }
>
>
> cmdargs asd fgh jkl
>
> output :
> ~~~~~~~~~~~~~~
>
> Name of the Program is 1668113505[/color]
When sending a wchar_t to a char based stream, it is printed as an integer,
not as a character. |