Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy from char *buff to CString? 1

Status
Not open for further replies.

sulacco

Technical User
Nov 8, 2002
74
RU
Hi, People. How to copy from char *buff to CString?
I've got such an sample:
Code:
	int size=file.GetLength();
	char *buff=new char(size);
	file.Read(buff,size);
	file.Close();

	strCont=*buff;
	//strCont=buff; don't work either
	delete [] buff;
	return strCount;
everything is good but after I try to delete [] buff; there is error.
I guess that I'm trying to delete the same chunk of memory 'cause
strCont and buff point at the same address. So I need to copy buff to
strCont.
With due respect.
 
Code:
char *buff=new char[size]; // Brackets!
...
strCont=buff; // Not *buff! Casting from *char to CString.
You allocate a char object with size value, then try to deallocate this scalar as an array...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top