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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I convert char[25000] to CString?

Status
Not open for further replies.

jvff

Programmer
Apr 1, 2001
64
BR
Hello,
I have this function to translate a text into a code, but I can't get it to work. Please help me.

Code:
char normal[25000];
char sc[25000];
int index;

GetDlgItemText(IDC_NORMAL, normal);

while(normal[index] != '\0')
{
	switch(normal[index])
	{
	case 'W':
	case 'w': sc[index] = '!';

	default: sc[index] = normal[index];
	}
}

SetDlgItemText(IDC_SC, sc);
[\code] ThanQ, ;-)

          JVFF (Janito Vaqueiro Ferreira Filho)
 
CString normal;
CString sc;
int index=0;

GetDlgItemText(IDC_NORMAL, normal);

while(normal.GetLength() > index)
{
switch(normal[index])
{
case 'W':
case 'w': sc += "!";

default: sc += normal[index];
}
index++;
}

SetDlgItemText(IDC_SC, sc);


 
Use stl
:)

and

to make you old code work you don't need to convert to CString but only andvance the index++; in the end of the loop iteration
Issahar Gourfinkel
senior software engineer
Softwatch LTD
Israel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top