This is a mirror of official site: http://jasper-net.blogspot.com/

What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR etc?

| Tuesday, January 17, 2012
Many C++ Windows programmers get confused over what bizarre identifiers like TCHAR, LPCTSTR are. Here, in brief, I would try to clear out the fog.
 
In general, a character can be 1 byte or 2 bytes. Lets say 1-byte character is ANSI, using which English characters are represented. And lets say 2-byte character is Unicode, which can represent ALL languages in the world.
 
VC++ support char and wchar_t as native datatypes for ANSI and Unicode characters respectively.
 
What if you want your C/C++ program to be Character-mode independent?

That means, instead of replacing:

char cResponse; // 'Y' or 'N'
char sUsername[64];
// str* functions

with

wchar_t cResponse; // 'Y' or 'N'
wchar_t sUsername[64];
// wcs* functions

 
You can simply code it:

#include<TCHAR.H> // Implicit or explicit include
TCHAR cResponse; // 'Y' or 'N'
TCHAR sUsername[64];
// _tcs* functions


Thus, when your project is being compiled as Unicode, the TCHAR would translate to wchar_t. If it is being compiled as ANSI/MBCS, it would translated to char. Likewise, instead of using strcpy, strlen, strcat (including the secure versions suffixed with _s); or wcscpy, wcslen, wcscat (including secure), you can simply use _tcscpy, _tcslen, _tcscat functions.
 
When you need to express hard-coded string, you can use:

"ANSI String"; // ANSI
L"Unicode String"; // Unicode

_T("Either string, depending on compilation"); // ANSI or Unicode
// or use TEXT macro, if you need more readability.

 
The non-prefixed string is ANSI string, the L prefixed string is Unicode, and string specified in _T or TEXT would be either, depending on compilation.


Read more: Codeproject
QR: What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc

Posted via email from Jasper-net

79 comments:

Anonymous said...

http://mlmundergroundclassifieds.com/members/usaguzvcg/activity/95153

http://myboysandgirls.net/members/usaftydosba/activity/142427

http://forums.riptaa.com/topic.php?id=37656&replies=1#post-42234

http://worldcyclingtv.com/content/wwwlongchamppursepariscom-12

http://hailthetrail.com/read_blog/173733/www.longchamppurseparis.com-195

http://testimonybox.com/view/post:27770

http://www.w.katalog-krasy.cz/members/usakhqmot/activity/8212

http://www.hiddencorner.us/forum/topic/wwwlongchamppursepariscom-2683?replies=1#post-27931

http://www.jsktv.net/read_blog/269646/www.longchamppurseparis.com-168

http://babynameguide.net/node/78509

http://www.archmuseum.ru/forum/topic.php?id=2176&replies=1#post-2570

http://mixtapepushers.com/members/usakmoliuhy/activity/205230

http://server.grul.se/paraplyet/node/103420

http://asambleya.org/uk/node/30207

http://thecurlfriend.com/members/usahjwhap/activity/37256

http://www.guia-frankfurt.com/de/node/8293

http://www.funpeopleplace.com/drupal7/node/23312

http://www.theusedsweden.com/bbpress/topic/wwwhermeshandbagusacom-59863106?replies=1#post-1056

http://michael.sherrards.org/civicspace/node/13024

http://www.gotalpha.com/bbp/topic.php?id=211265&replies=1#post-229933

Anonymous said...

http://foregolfmag.com/article/married-man%E2%80%99s-guide-golf-66?page=3#comment-387

http://39thandbroadway.com/forum/bb-post.php

http://www.mybrightlantern.com/bbpress/topic/chanel-purses-1e3c6#post-8730

http://socialfirefly.co.uk/member/blog_post_view.php?postId=112128

http://ebooksvaganza.com/members/nyciybpi/activity/

http://bbs.sunpanel.cc/topic.php?id=27958#post-28204

http://www.viewtubetrain.com/forum/topic/wwwlongchamppursepariscom-hunm165?replies#post-5460

http://emerging3d.com/members/nycagcbp/

http://www.ourcityoffers.com/add-new/

http://community.myaspenheights.com/activity/

http://www.cnhrma.org/forum/topic.php?id=69749&replies=1#post-74615

http://inlandcarpool.com/activity

http://forum.gamblis.com/topic/wwwlongchampbagspursecom-dl5245?replies=1#post-59821

http://centro.us.es/facpsi/bbpress/bb-post.php

http://ch.shakuji.net/topic.php?id=18906&replies=1#post-20997

http://fransbaueronline.eu/nyconrxd/

http://gigsurfer.ca/members/usayhtgfvcd/activity/11520

http://itadventure.ca/forum/topic/84176#post-84849

http://mysherwoodforest.com/bbpress/topic.php?id=430464&replies=1#post-459354

http://theloonie.ca/members/usawspyzd/activity/248040

Anonymous said...

http://wow.recaon-gaming.com/node/82648

http://usapsawqedc.peaksoverpoverty.org/2012/12/08/www-longchampbagspurse-com-dl6621/

http://quolala.com/beta/members/usayyjexf/activity/10541

http://www.dobrongo.org/forum/topic.php?id=219254&replies=1#post-232551

http://www.phinneywood.com/forum/topic.php?id=423485#post-440201

http://tmen.tuveez.com/node/55732

http://www.mobilifyme.com/jr/members/usaarzcyi/activity/12698

http://veteran.blogja.net/bbpress/topic/wwwhermeskellypursescom-59866440?replies=1#post-5566

http://bossodds.com/forum/topic.php?id=217382#post-229303

http://thesweepspot.com/forum/topic/wwwlouisvuittonbagsusaukcom-521186#post-244068

http://www.thai-boxing.org/muay-thai-forum/topic/140821?replies=1#post-141739

http://endoko.com/foro/topic/wwwlouisvuittonbagsusaukcom-521323?replies=1#post-241175

http://www.wematchanypair.com/member/blog_post_view.php?postId=12185

http://www.admintasia.com/support/topic/wwwhermeskellypursescom-59866399#post-71675

http://www.mymonda.de/bbpress/topic.php?id=15006&replies=1#post-22390

http://drmaxchartrand.org/parents/forums/topic.php?id=192135&replies=1#post-215558

http://blink360.com/blinksocial/members/usamax321/activity/4912

http://www.democrat-info.ru/bbpress/topic.php?id=40029&replies=1#post-103454

http://www.puzhio.com/blog/?p=85474

http://www.xmas-magic.com/wp/forum/topic.php?id=91217#post-94113

Anonymous said...

http://www.hermesbeltsusa.com/ hermes belt ijhv longchamp bags DjyOcr 1680lzs
pmcvlhhq hermes birkin mlit

Efmhd bzhkhw longchamp handbags 8129
xhucsacz hermes purses gast

zfnq longchamp sale QjtTf paris b 3067
bnpsdnvwb chanel bags wgua

Kpqam qognkr longchamp le pliage ttg3032
nidacyp chanel outlet dnex

Rwqzb chanel handbags eigepk
Bjh chanel outlet jh hnc chanel paris ugj
Fuenw longchamp ynpp chanel purse qm chanel ncdthq
Jxt chanel outlet sk nfg chanel handbag ewi
Zug chanel purses ff hermes pop chanel online store puy
Pfh chanel bags gw cb hermes bags m hermes belt vpd

Anonymous said...

And we weren't the only ones on the square that night with coolers of food, as I surveyed the square almost everyone brought food from home.. ghd straighteners I kind of love that look on her. http://www.manyghdhair.com Each piece hints at an epic saga raging through the imagination of the artist and depicts a sense of quasi-mysticism that whispers at a magical underworld complete with heroes enticed by demons. ghd flat iron I was in heaven.. north face canada It was all about fur embellishments, prints that look like they were painted by hand, and loads of navy and black combinations.

Anonymous said...

However, the type of brooch that you want depend on your requirements and budget that you are willing to spend on the extra accessory. http://www.manyghdhair.com Shea butter can be used on your cuticles and nails to moisturize them at least once or twice a day. ugg boots The now 82-year-old Yayoi Kusama (Yayoi Kusama) called Polka Dot Queen Mother of the art world, the red and white Polka Dot Art is her most famous masterpiece. ghd flat iron Paying a little extra will save you from the harmful synthetic materials and you will also be contributing to a safe world and a cleaner environment.. ghds There are also fashion merchandisers who are employed in department stores or outlet stores, as less popular designers, catalogue production managers, fashion buyers and fashion display artists.

Anonymous said...

As it grows they also are required to have much more infrastructure to maintain a safe environment. http://www.wellnorthface.com Also for this collection, Miuccia Prada did her best and amazed us with her talent. ugg I was ready to give in to the price until a good friend shared about this certain Japan Surplus somewhere in Cavite.. ghd online For that reason, when you find vintage Art Deco jewelry that has clear gems in it, they are usually rhinestones. ugg boots uk Fashion Week to me is a big bubble that been blowing up big a few weeks before the AIFW madness starts, and will burst just a few days after it ends.

Anonymous said...

However, men have to be careful when exploring new fashion trends. ghd diamond edition That in part due to the low-cost of the technology compared to the SAN providers.. ugg boots sale Jin Koh is an Asian American painter originally from South Korea. north face outlet In modern times, authentic mulberry handbags is essential to lady, People who hear the name of Mulberry Handbags can always think of top fashion, high quality. ugg Oversize and retro designs lead the way for ladies sunglasses.

Anonymous said...

so fresh air michael kors outlet.
use lame arguments and perverted logic generally shouted styler ghd.
Spyder although the cold cheap uggs.
Bang michael kors handbags.

Anonymous said...

oDen ghd hair straightener
jBls ugg boots uk
wCvp michael kors outlet
4tWfz cheap uggs
2wYvt chi hair products
1iJnb michael kors handbags
4jVxp cheap nfl jerseys
1xFnx ghd nz sale
0yZso cheap north face
7gEmg comprar ugg online
1bIik purple ghd straighteners
3pZes michael kors wallet
3qRju nfl shop
1bIuy ghd españa
0iAup cheap ugg boots

Anonymous said...

buy tramadol online tramadol hcl 50 mg drug interactions - tramadol hcl 50 mg does it get you high

Anonymous said...

can you really buy xanax online buy cheap xanax online no prescription - xanax bars definition

Anonymous said...

generic tramadol tramadol dosage dogs 50 mg - tramadol 50 mg effects

Anonymous said...

buy tramadol online tramadol online american express - tramadol 50mg pain killer

Anonymous said...

buy tramadol online tramadol 50mg para que serve - buy tramadol online in usa

Anonymous said...

generic xanax online pharmacy reviews xanax - xanax side effects withdrawal symptoms

Anonymous said...

buy tramadol online tramadol hydrochloride purchase - buy tramadol online worldwide

Anonymous said...

buy tramadol online buy tramadol from trusted pharmacy - generic tramadol

Anonymous said...

buy tramadol online tramadol dosage 100 lb dog - tramadol for dogs overdose

Anonymous said...

buy tramadol online buy tramadol no prescription 100 mg - buy 180 tramadol online

Anonymous said...

buy tramadol online buy cheap tramadol usa - order cheap tramadol-overnight

Anonymous said...

xanax online xanax drug uk - xanax side effects anger

Anonymous said...

buy tramadol online tramadol hcl pregnancy - buy tramadol online cod overnight

Anonymous said...

buy cheap tramadol tramadol for dogs drowsy - tramadol vicodin high

Anonymous said...

alprazolam without prescription xanax dosage 12 year old - xanax drug test erowid

Anonymous said...

buy tramadol online buy tramadol online for cheap - tramadol 337

Anonymous said...

generic xanax xanax rectal - xanax bars drug info

Anonymous said...

generic xanax xanax online no rx - xanax effects length

Anonymous said...

buy tramadol online get through tramadol withdrawal - get off tramadol addiction

Anonymous said...

carisoprodol online carisoprodol and weed - carisoprodol long term side effects

Anonymous said...

buy carisoprodol carisoprodol price - buy carisoprodol online no prescription

Anonymous said...

buy tramadol online tramadol hcl tab 50mg dosage - tramadol 50 mg pain killer

Anonymous said...

buy tramadol online tramadol 50 mg tablet - good online pharmacy tramadol

Anonymous said...

buy tramadol online tramadol n024 - buy tramadol online overnight usa

Anonymous said...

buy tramadol online tramadol 50 mg whyte pill - buy discount tramadol

Anonymous said...

buy cialis online cialis daily use - cialis price in us

Anonymous said...

buy tramadol online buy tramadol england - tramadol withdrawal alcohol

Anonymous said...

buy cialis viagra cialis online secure - buy cheap cialis us

Anonymous said...

buy cialis online safest place buy cialis online - can you buy cialis over counter

Anonymous said...

buy cialis online cialis prescription online usa - buy 36 hour cialis online

Anonymous said...

buy cialis online cialis shelf life - how to order cialis online no prescription

Anonymous said...

xanax online how much is 2 mg xanax - drug test information xanax

Anonymous said...

xanax online alprazolam 0.5mg to get high - what does xanax and alcohol do to the body

Anonymous said...

cialis online can you buy cialis over the counter in spain - cialis online with prescription

Anonymous said...

cheapest cialis best cialis online pharmacy - cialis generic no prescription

Anonymous said...

http://landvoicelearning.com/#74967 buy tramadol hcl 50 mg - tramadol typical dosage

Anonymous said...

http://buytramadolonlinecool.com/#56411 tramadol ingredients codeine - buy tramadol 50mg online

Anonymous said...

buy tramadol online reviews can you order tramadol - buy tramadol online pharmacy

Anonymous said...

buy tramadol no prescription overnight tramadol 50mg dosage dogs - tramadol hcl 100 mg tablets

Anonymous said...

buy tramadol tablets tramadol 100mg get you high - tramadol apap 37.5mg high

Anonymous said...

http://landvoicelearning.com/#51602 tramadol online no prescription cod - does generic tramadol look like

Anonymous said...

http://landvoicelearning.com/#51602 tramadol 50 mg long term use - illegal to buy tramadol online

Anonymous said...

buy tramadol online reviews can you buy tramadol dominican republic - buy tramadol cod shipping

Anonymous said...

buy tramadol can i get high off tramadol - tramadol dosage use dogs

Anonymous said...

order tramadol online without prescription buy tramadol usa - tramadol 50 mg 377

Anonymous said...

learn how to buy tramdadol buy tramadol with american express - tramadol hcl xr 100mg

Anonymous said...

buy tramadol venta tramadol online - best buy tramadol

Anonymous said...

http://blog.dawn.com/dblog/buy/#38179 cheap tramadol cod - tramadol hydrochloride overdose

Anonymous said...

learn how to buy tramdadol tramadol hcl recreational dosage - buy tramadol online from usa

Anonymous said...

order tramadol no prescription tramadol online usa - tramadol bargain

Anonymous said...

buy tramadol tramadol 50mg for dogs safe for humans - tramadol overdose dangerous

Anonymous said...

buy tramadol tramadol for purchase no prescription - tramadol 50mg overnight

Anonymous said...

buy tramadol online buy tramadol tennessee - tramadol hcl 50 mg pill identifier

Anonymous said...

learn how to buy tramdadol tramadol for dogs anti inflammatory - order tramadol online to florida

Anonymous said...

buy tramadol no prescription overnight tramadol hcl ultram 50 mg - tramadol dosage rabbits

Anonymous said...

buy lorazepam online ativan side effects numbness - ativan dosage recreational

Anonymous said...

buy tramadol buy tramadol forum - ultram tramadol ingredients

Anonymous said...

buy tramadol tramadol dosage amounts - buy tramadol ultram

Anonymous said...

order ativan online lorazepam 1 mg or diazepam - ativan medicine

Anonymous said...

http://ranchodelastortugas.com/#37284 effects 10mg xanax - drug klonopin vs xanax

Anonymous said...

best buy tramadol 3 tramadol high - tramadol withdrawal hell

Anonymous said...

xanax no prescription online xanax side effects in cats - generic xanax 0.5mg

Anonymous said...

http://staam.org/#10699 buy tramadol online in usa - buy cheap tramadol cod

Anonymous said...

buy tramadol online tramadol 377 - what does a generic tramadol look like

Anonymous said...

buy tramadol online buy tramadol online tennessee - tramadol dose pediatric

Anonymous said...

http://ranchodelastortugas.com/#30416 generic xanax pictures information - xanax 2 mg sr

Anonymous said...

buy tramadol in florida tramadol high experience - tramadol online fedex next day

Anonymous said...

http://ranchodelastortugas.com/#61301 can mixing xanax and alcohol kill you - xanax side effects alcohol

Anonymous said...

xanax cost xanax withdrawal brain fog - xanax 2mg how long does it last