GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-May-2008, 11:55
komalwaseem komalwaseem is offline
New Member
 
Join Date: Apr 2008
Posts: 6
komalwaseem is on a distinguished road

char - CString ??


On the Dialog Box, the user enters his/her name in an edit box and I save that name in a dynamically allocated array :

CPP / C++ / C Code:
	           UserName = new char*[NumberOfUsers];
		for(int a=0; a<NumberOfUsers; a++)
		{
			UserName[a] = new char[25];
		}

*(UserName[UserNo]) = m_UserName;
Now this last statment gives me an error because UserName is char type and the value I take in the edit box is CString... what do I do ???
Last edited by LuciWiz : 09-May-2008 at 07:13. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 07-May-2008, 12:31
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 511
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: char - CString ??


With char pointers, you can't just set the value of it. You have to use a function like strcpy(). Of course, first, you'll have to convert the CString into a single-byte string type.
  #3  
Old 07-May-2008, 12:55
komalwaseem komalwaseem is offline
New Member
 
Join Date: Apr 2008
Posts: 6
komalwaseem is on a distinguished road

Re: char - CString ??


ya but how do change CString ???
  #4  
Old 07-May-2008, 13:07
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 511
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: char - CString ??


Why not make your array an array of CString objects or change them from char* to TCHAR*?
  #5  
Old 10-May-2008, 11:55
komalwaseem komalwaseem is offline
New Member
 
Join Date: Apr 2008
Posts: 6
komalwaseem is on a distinguished road

Re: char - CString ??


hey thanks for the help but the problem got solved just by using strcpy ..didn't have to convert anything into CString or char !!!!!
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointer initialization causing program abend? emanresu C Programming Language 0 12-Dec-2006 10:36
lvalue compile error emanresu C Programming Language 7 16-Nov-2006 10:22
getting an error while compiling and running using different IDE. jaro C Programming Language 0 25-Aug-2006 09:14
Memory cannot be read? dlare9 C Programming Language 3 16-Nov-2005 07:03
Debug Assertion Failed! dlare9 C Programming Language 3 13-Nov-2005 23:18

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:29.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.