|
-
August 20th, 2007, 10:09 AM
#1
L macro
Hello everyone,
I am using Visual Studio 2003 and Windows Console project, I find when using L macro to convert character to wide character, the compiler will report an error that L macro is not defined.
I find it is not defined in either <windows.h> or <TCHAR.h> -- when adding the two header files, the compile error is the same.
Could anyone explain how to use L macro in Visual Studio 2003 and Windows Console project? Which header file is needed?
thanks in advance,
George
-
August 20th, 2007, 10:43 AM
#2
Re: L macro
1) I don't think there is an "L macro". I think it is merely designates
a wide character or a string literal made up of wide characters.
2) an example:
Code:
#include <string>
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
wstring w = L"Hello";
wcout << w << L'\n';
return 0;
}
-
August 20th, 2007, 11:00 AM
#3
Re: L macro
 Originally Posted by Philip Nicoletti
1) I don't think there is an "L macro". I think it is merely designates
a wide character or a string literal made up of wide characters.
2) an example:
Code:
#include <string>
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
wstring w = L"Hello";
wcout << w << L'\n';
return 0;
}
New term for me wcout and wstring,
Philip brother can you explain it to me what's the importance of using wcout and wstring
-
August 20th, 2007, 11:05 AM
#4
Re: L macro
wcout - The object controls insertions to the standard output as a wide stream.
wstring - A type that describes a specialization of the template class basic_string with elements of type wchar_t.
Appreciate others by rating good posts
"Only buy something that you'd be perfectly happy to hold if the market shut down for 10 years." - Warren Buffett
-
August 20th, 2007, 10:22 PM
#5
Re: L macro
Thanks Philip,
If L is not a macro, what is it?
I find my previous fault is I am compiling a C file (.c) and when I rename the file to .cpp, it could compile.
regards,
George
 Originally Posted by Philip Nicoletti
1) I don't think there is an "L macro". I think it is merely designates
a wide character or a string literal made up of wide characters.
2) an example:
Code:
#include <string>
#include <iostream>
using namespace std;
int main (int argc, char** argv)
{
wstring w = L"Hello";
wcout << w << L'\n';
return 0;
}
-
August 21st, 2007, 02:23 PM
#6
Re: L macro
If L is not a macro, what is it?
It's part of the definition and syntax of the language. It's no different (in principle) from use of "F" at the end of a number to indicate a float, or "0x" at the beginning of a number to indicate a hex number.
Mike
-
August 21st, 2007, 08:24 PM
#7
Re: L macro
Thanks Mike,
 Originally Posted by MikeAThon
It's part of the definition and syntax of the language. It's no different (in principle) from use of "F" at the end of a number to indicate a float, or "0x" at the beginning of a number to indicate a hex number.
Mike
I want to confirm that L can only be used in C++ and can not be used in C?
regards,
George
-
August 21st, 2007, 11:44 PM
#8
Re: L macro
 Originally Posted by George2
I want to confirm that L can only be used in C++ and can not be used in C?
Valid for both!
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
August 22nd, 2007, 01:52 AM
#9
Re: L macro
Thanks exterminator,
 Originally Posted by exterminator
Valid for both!
I have tried that it works for both. It is my careless fault before.
regards,
George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|