Good day!

Please tell me how to see the value in argv [] after all, read the principle of operation and read everything connected with it, but it’s even banal:

int _tmain(int argc, _TCHAR* argv[]) { if(argc==1){ std::cout<<"Non arg\n"; return 0; } for(int i = 0; i < argc; ++i){ std::cout<<argv[i]<<"\n"; } return 0; } 

displays me the address. And how would you look at the addresses, and right here is the parameter? where I don’t look at all authors the examples converge on this, but when you compile and run them, then in the end I get the addresses of my arguments.

    2 answers 2

    Well, as far as I understand, standard cout does not digest unicode and wchar_t.

    But this is likely to work:

     for(int i = 0; i < argc; ++i) { std::wcout << argv[i] << std::endl; } 
    • thanks, it worked. - rojaster

    It's all insane madhouse from MS. You hammer on this bad type and use the normal one: it is still unbearable. If you really want Unicode, use the intended data types (wchar_t *), or do not suffer and just use char *.

    On the other hand, in theory, TCHAR should turn into either char or wchar_t

    So, I started like you, only with char * (I don’t have TCHAR) and everything worked, so I don’t understand how you get the addresses:

     cy6ergn0m@localhost tests/cpp $ cat main.cxx #include <iostream> using namespace std; int main(int argc, char * argv[]) { for(int i = 0; i < argc; ++i) cout << argv[i] << endl; return 0; } cy6ergn0m@localhost tests/cpp $ g++ main.cxx -o test cy6ergn0m@localhost tests/cpp $ ./test aaa bbb ccc ./test aaa bbb ccc 
    • X is in my plans, the university is on the windows and I focused so far under MS, and so TCHAR is redefined in MVS2010 as char, I climbed into the settings. - rojaster
    • your advice took note. - rojaster
    • one
      _TCHAR is a foolish intolerance of M $. <P> Although it is logical that there may be unicode on the command line ... Therefore, it is necessary to use it. - gecube 1:16 pm