• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 19:56
CEST 01:56
KST 08:56
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Tournament Spotlight: FEL Cracow 20259Power Rank - Esports World Cup 202577RSL Season 1 - Final Week9[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18
Community News
[BSL 2025] H2 - Team Wars, Weeklies & SB Ladder0EWC 2025 - Replay Pack1Google Play ASL (Season 20) Announced26BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams10Weekly Cups (July 14-20): Final Check-up0
StarCraft 2
General
#1: Maru - Greatest Players of All Time EWC 2025 - Replay Pack Tournament Spotlight: FEL Cracow 2025 Power Rank - Esports World Cup 2025 I offer completely free coaching services
Tourneys
FEL Cracov 2025 (July 27) - $10,000 live event Esports World Cup 2025 $25,000 Streamerzone StarCraft Pro Series announced $5,000 WardiTV Summer Championship 2025 WardiTV Mondays
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 484 Magnetic Pull Mutation #239 Bad Weather Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune
Brood War
General
BEST RECOVERY EXPERTS FOR BITCOIN,CRYPTO,USDT HIRE Google Play ASL (Season 20) Announced [BSL 2025] H2 - Team Wars, Weeklies & SB Ladder [Update] ShieldBattery: 2025 Redesign Dewalt's Show Matches in China
Tourneys
[Megathread] Daily Proleagues [BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational [CSLPRO] It's CSLAN Season! - Last Chance
Strategy
Simple Questions, Simple Answers [G] Mineral Boosting Does 1 second matter in StarCraft?
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok) Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
UK Politics Mega-thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread [\m/] Heavy Metal Thread Movie Discussion! [Manga] One Piece Korean Music Discussion
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
Ping To Win? Pings And Their…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Socialism Anyone?
GreenHorizons
Eight Anniversary as a TL…
Mizenhauer
Customize Sidebar...

Website Feedback

Closed Threads



Active: 643 users

[H] A quick C++(win32) question

Blogs > Ethenielle
Post a Reply
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
September 16 2008 16:41 GMT
#1
Hello thar,

I'm learning to program Windows(still) and it's going ok - finally got the grasp on UNICODE(I think!). But I'm wondering a bit about functions that accept a pointer as an argument, CreateWindow for instance:

hwnd = CreateWindow (LPCTSTR lpClassName, LPCTSTR lpWindowName, ...);

As far as I've understood, LPCTSTR is a long pointer to a string, so I'd expect to pass it something like this:

TCHAR hi[] = TEXT("hello");
hwnd = CreateWindow(&hi, &hi, ...);

Or a pointer to that variable. But instead I can just pass the TCHAR variable and that's what works. What am I missing here?

Thanks in advance for any help!

Theres a fine line between fishing and just standing on the shore like an idiot.
Darthdrunken
Profile Joined January 2006
Germany50 Posts
Last Edited: 2008-09-16 17:03:25
September 16 2008 16:59 GMT
#2
As far as i remember LPCTSTR isn't a pointer but an actual String, so your definition of the variable hi is exactly the correct data-type(sorry i only know this expression in german but i think you'll get what i mean).
1a2a3atttgg
Aerox
Profile Blog Joined September 2004
Malaysia1213 Posts
September 16 2008 17:07 GMT
#3
LPCTSTR = Long Pointer to a Const TCHAR STRing ^^
"Eyes in the sky."
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
Last Edited: 2008-09-16 18:40:31
September 16 2008 18:38 GMT
#4
I think c++ has an implicit convert from an array of char(I think that's the type of a string literal) to a PChar
LiquipediaOne eye to kill. Two eyes to live.
HeavOnEarth
Profile Blog Joined March 2008
United States7087 Posts
September 16 2008 18:39 GMT
#5
lmaooo xD
"come korea next time... FXO house... 10 korean, 10 korean"
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
Last Edited: 2008-09-16 18:46:55
September 16 2008 18:46 GMT
#6
Stroustrup on string literals:
The type of a string literal is ‘‘array of the appropriate number of const characters,’’ so "Bohr" is
of type "const char [5]".
A string literal can be assigned to a char *. This is allowed because in previous definitions of C
and C++ , the type of a string literal was char *. Allowing the assignment of a string literal to a
char* ensures that millions of lines of C and C++ remain valid. It is, however, an error to try to
modify a string literal through such a pointer
LiquipediaOne eye to kill. Two eyes to live.
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
September 16 2008 19:11 GMT
#7
Aha, so that's how it is Thanks a lot for the help!

On September 17 2008 03:39 HeavOnEarth wrote:
lmaooo xD


Happy to entertain I guess ...?
Theres a fine line between fishing and just standing on the shore like an idiot.
HeavOnEarth
Profile Blog Joined March 2008
United States7087 Posts
September 17 2008 04:35 GMT
#8
oh i was just like "lmao ( I DONT GET ANYTHING OF THIS) xD "
of course i didn't feel it necessary to post the parenthesis' part at the time!
"come korea next time... FXO house... 10 korean, 10 korean"
haduken
Profile Blog Joined April 2003
Australia8267 Posts
September 17 2008 05:07 GMT
#9
it's one of those C miseries that survived through the ages. You shouldn't really base your code on something like this but it's quite neat to know and it's one of the major causes of errors in code.
Rillanon.au
araav
Profile Blog Joined September 2004
Armenia1590 Posts
September 17 2008 07:00 GMT
#10
TCHAR hi[] = TEXT("hello");

&hi is a pointer to an array of TCHARs, which is not a pointer to TCHARs, which is expected by CreateWindow.
Instead, you would use hi, as it's an array, which is implicitely converted to TCHAR *.
Or you would use &hi[0] to explicitely state what you really want..

btw, an advice: use const for everything that are not going to change (hi).
The flower that blooms in adversity is the most rare and beautiful of all.
Divinek
Profile Blog Joined November 2006
Canada4045 Posts
September 17 2008 07:09 GMT
#11
On September 17 2008 13:35 HeavOnEarth wrote:
oh i was just like "lmao ( I DONT GET ANYTHING OF THIS) xD "
of course i didn't feel it necessary to post the parenthesis' part at the time!


Yeah, then the post might have some relevance to it. God forbid
Never attribute to malice that which can be adequately explained by stupidity.
Oh goodness me, FOX tv where do you get your sight? Can't you keep track, the puck is black. That's why the ice is white.
Please log in or register to reply.
Live Events Refresh
Next event in 11h 4m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 158
Ketroc 27
StarCraft: Brood War
NaDa 49
MaD[AoV]17
Dota 2
capcasts388
League of Legends
Grubby4559
febbydoto22
Counter-Strike
Fnx 2342
fl0m2079
Stewie2K696
flusha345
Super Smash Bros
hungrybox3323
Mew2King1513
AZ_Axe419
Heroes of the Storm
Khaldor230
Other Games
tarik_tv21770
summit1g15150
gofns9771
JimRising 621
ROOTCatZ326
Maynarde164
Organizations
Other Games
gamesdonequick3098
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• davetesta113
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki9
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Stormgate
• mYiSmile10
League of Legends
• Doublelift6703
Other Games
• Scarra2096
• imaqtpie1505
Upcoming Events
Wardi Open
11h 4m
Sparkling Tuna Cup
1d 10h
WardiTV European League
1d 16h
Online Event
1d 17h
uThermal 2v2 Circuit
2 days
The PondCast
3 days
Replay Cast
4 days
Korean StarCraft League
5 days
CranKy Ducklings
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

CSLPRO Last Chance 2025
Esports World Cup 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL 20 Non-Korean Championship
BSL 20 Team Wars
CC Div. A S7
Underdog Cup #2
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25

Upcoming

ASL Season 20: Qualifier #1
ASL Season 20: Qualifier #2
ASL Season 20
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
Maestros of the Game
SEL Season 2 Championship
WardiTV Summer 2025
uThermal 2v2 Main Event
HCC Europe
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.