Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

defining a string from a string macro

Status
Not open for further replies.

FlashAsh99

Programmer
Mar 4, 2008
2
0
0
FI
Suppose I have something like...

#define FIRSTSTRING "my string 1"
...

char[] secondString = L"my string 2"
char[] firstString = ???


Where there is ???, What do I put here to set firstString to the value of FIRSTRING macro, similar to how secondString is set.
 
Something like...
Code:
#define FIRSTSTRING "my string 1"

char  firstString[] = FIRSTSTRING;
 
Code:
char[] secondString = L"my string 2"
The char should be wchar_t if you want UNICODE, and that's not where the brackets go.
 
Ok I have tried something this...

#define FIRSTSTRING "my string 1"

....

wchar_t myString[] = L""FIRSTRING;

and I get the error message concatenating mismatched strings
Concatenating wide "" with narrow "my string 1".


How to I get myString to be a wide string from the macro?

 
Why do you have "" between the L and the macro?
That would expand to:
Code:
wchar_t myString[] = L"""my string 1";
which makes no sense.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top