convert TCHAR to CString
-
hi, i have the below code.. TCHAR buffer[SIZEOFTCHAR]; ::GetSystemDirectory(buffer,SIZEOFTCHAR); CString csPath; csPath+=_T(""); i want to copy value in buffer to csPath and i want to append other string to csPath.Please let me know...
No need to convert anything, you can simply assign your buffer in your CString object:
CString csPath = buffer;
If you need to concatenate your buffer at the end of the CString content, you can also do it like this:
CString csPath = "Something";
csPath += buffer;BTW, what is SIZEOFTCHAR ? What is its value ? If it is the size of one character, then your string will only be able to contain 1 single character, so I guess this is not really what you want.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
No need to convert anything, you can simply assign your buffer in your CString object:
CString csPath = buffer;
If you need to concatenate your buffer at the end of the CString content, you can also do it like this:
CString csPath = "Something";
csPath += buffer;BTW, what is SIZEOFTCHAR ? What is its value ? If it is the size of one character, then your string will only be able to contain 1 single character, so I guess this is not really what you want.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Thanks for ur Reply..... but the issueis... TCHAR buffer[8000]; ::GetSystemDirectory(buffer,8000); i need add the below string to the path which is obtained from above function.. CString csPath; csPath=_T("\\")+"files.ini"; Please help me..
TCHAR buffer[8000];
if (! ::GetSystemDirectory(buffer,8000))
{
// handle error
}
CString csPath(buffer);
csPath += _T("\\files.ini");:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Thanks for ur Reply..... but the issueis... TCHAR buffer[8000]; ::GetSystemDirectory(buffer,8000); i need add the below string to the path which is obtained from above function.. CString csPath; csPath=_T("\\")+"files.ini"; Please help me..
p_1960 wrote:
i need add the below string to the path which is obtained from above function.. CString csPath; csPath=_T("\\")+"files.ini";
CString csPath = buffer;
csPath += _T("\\files.ini");Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Thanks for ur Reply..... but the issueis... TCHAR buffer[8000]; ::GetSystemDirectory(buffer,8000); i need add the below string to the path which is obtained from above function.. CString csPath; csPath=_T("\\")+"files.ini"; Please help me..
p_1960 wrote:
TCHAR buffer[8000];
What's your fetish with the number 8000? :rolleyes:
It is a crappy thing, but it's life -^ Carlo Pallini
-
p_1960 wrote:
TCHAR buffer[8000];
What's your fetish with the number 8000? :rolleyes:
It is a crappy thing, but it's life -^ Carlo Pallini
I make a guess: This sample [^] uses
32767
, that is**0x**8000-1
(Well..., actually the two things are probably unrelated...) :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I make a guess: This sample [^] uses
32767
, that is**0x**8000-1
(Well..., actually the two things are probably unrelated...) :-DIf the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]CPallini wrote:
This sample [^] uses 32767, that is 0x8000-1 (Well..., actually the two things are probably unrelated...)
thats probably best answer i ever got!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
CPallini wrote:
This sample [^] uses 32767, that is 0x8000-1 (Well..., actually the two things are probably unrelated...)
thats probably best answer i ever got!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
Thank you, anyway I guess you got too few answers in you life... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Thank you, anyway I guess you got too few answers in you life... :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
CPallini wrote:
Thank you, anyway I guess you got too few answers in you life
i thought you are taliking about question
Just kidding, pal (I know, I often forgot the joke icon... :rolleyes: ) :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
No need to convert anything, you can simply assign your buffer in your CString object:
CString csPath = buffer;
If you need to concatenate your buffer at the end of the CString content, you can also do it like this:
CString csPath = "Something";
csPath += buffer;BTW, what is SIZEOFTCHAR ? What is its value ? If it is the size of one character, then your string will only be able to contain 1 single character, so I guess this is not really what you want.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++CString is 16 bit under unicode but 8bit under non unicode version i guess. but so underunicode version direct conversion can be done as TCHAR is unsigned short. where in non unicode version, WideCharToMultiByte() can be used