syntax error

A

Aston Martin

can anyone tell why the hell this code is not compiling ?

#include <tchar.h>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

#ifdef UNICODE
typedef wstring tstring;
typedef wcout tcout;
typedef wcin tcin;
#else
typedef string tstring;
typedef cout tcout;
typedef cin tcin;
#endif

typedef vector<tstring> StringVector;
int cpp_main( StringVector );

int _tmain(int argc, _TCHAR* argv[])
{
StringVector cpp_argv;
for( int i=0; i<argc; i++ )
cpp_argv.push_back( tstring( argv ) );
return cpp_main( cpp_argv );
}

int cpp_main( StringVector argv )
{
for( StringVector::const_iterator iter = argv.begin(); iter !=
argv.end(); iter++ )
tcout << *iter << endl;
return 0;
}
 
P

peter koch

Aston Martin skrev:
can anyone tell why the hell this code is not compiling ?

#include <tchar.h>

tchar is not standard. Did you know that?
#include<iostream>
#include<vector>
#include<string>
using namespace std;

#ifdef UNICODE
typedef wstring tstring;
typedef wcout tcout;
typedef wcin tcin;
#else
typedef string tstring;
typedef cout tcout;
typedef cin tcin;
#endif
cout/cin/wcout/wcin are not types but variables.
typedef vector<tstring> StringVector;
int cpp_main( StringVector );

int _tmain(int argc, _TCHAR* argv[])

_tmain is not main. But you probably know that? If you want to provide
code to this forum, you should provide code that compiles in standard
C++.
{
StringVector cpp_argv;
for( int i=0; i<argc; i++ )
cpp_argv.push_back( tstring( argv ) );
return cpp_main( cpp_argv );
}

int cpp_main( StringVector argv )
{
for( StringVector::const_iterator iter = argv.begin(); iter !=
argv.end(); iter++ )
tcout << *iter << endl;
return 0;
}


/Peter
 
H

Howard

Aston Martin said:
can anyone tell why the hell this code is not compiling ?

How about first you tell us what error(s) you're getting and for which lines
of code?

-Howard
 
V

vinnitu

you can do it such

#ifdef UNICODE
typedef wstring tstring;
#DEFINE tcout wcout
#DEFINE tcin wcin
#else
typedef string tstring;
#DEFINE tcout cout
#DEFINE tcin cin
#endif

like me
 
X

Xian

vinnitu said:
you can do it such

#ifdef UNICODE
typedef wstring tstring;
#DEFINE tcout wcout
#DEFINE tcin wcin
#else
typedef string tstring;
#DEFINE tcout cout
#DEFINE tcin cin
#endif

like me

I can't. But when I change #DEFINE to #define it works more.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top