C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 7th, 2006, 08:49 PM
TestingTimes TestingTimes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 TestingTimes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 41 sec
Reputation Power: 0
Please Help: Formatted TCHAR to LPTCSTR

Hello

This has got me stumped and I'm sure the answer is easy.
Visual C++ Unicode

This Works......
TCHAR *buffer;
buffer = _T("hello"); //ok
LPCTSTR Message = buffer;

when Message is used it outputs "hello"

This Doesn't......
TCHAR bufa[30];
TCHAR *buffer= bufa;
int field1 = 9;
swprintf(bufa, L"number is %d",field1);
LPCTSTR Message = buffer;

This displays nothing.

Please help, this is driving me nuts.....

Last edited by TestingTimes : March 10th, 2006 at 05:02 AM. Reason: typo

Reply With Quote
  #2  
Old March 8th, 2006, 08:57 AM
TestingTimes TestingTimes is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 2 TestingTimes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 41 sec
Reputation Power: 0
Fixed now...

A good nights sleep, a few typos fixed and ensuring that variables are public makes all the difference.


Quote:
Originally Posted by TestingTimes
Hello

This has got me stumped and I'm sure the answer is easy.
Visual C++ Unicode

This Works......
TCHAR *buffer;
buffer = _T("hello"); //ok
LPCTSTR Message = buffer;

when Message is used it outputs "hello"

This Doesn't......
TCHAR bufa[30];
TCHAR *buffer= bufa;
int field1 = 9;
swprintf(bufa, L"number is %d",field1);
LPCTSTR Message = buffer;

This displays nothing.

Please help, this is driving me nuts.....

Reply With Quote
  #3  
Old March 11th, 2006, 02:24 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Quote:
Originally Posted by TestingTimes
A good nights sleep, a few typos fixed and ensuring that variables are public makes all the difference.


Its because it is LPCTSTR instead of LPCSTR. The latter is char8 while former is TCHAR *.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Please Help: Formatted TCHAR to LPTCSTR


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT