Conversion Question 
Author Message
 Conversion Question

Please help, I have the following code with the following error:

WIN32_FIND_DATA FileData;
char stringdata [8192];
...
strcat(stringdata, FileData.cFileName);

error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned short
[260]' to 'const char *'

How can I concatenate the to the end of stringdata?  I tried casting it,
which is legal, but it gives me funny characters.

Thanks,
Jim



Wed, 09 Feb 2005 00:34:25 GMT  
 Conversion Question
You are mixing Unicode strings, like that in the WIN32_FIND_DATA with
single-byte character strings, as in the stringdata member.  You probably
don't want to do that, anyway.  Use _tcscat(), not strcat(), and make
stringdata an array of TCHAR, not char.

Paul T.


Quote:
> Please help, I have the following code with the following error:

> WIN32_FIND_DATA FileData;
> char stringdata [8192];
> ...
> strcat(stringdata, FileData.cFileName);

> error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned short
> [260]' to 'const char *'

> How can I concatenate the to the end of stringdata?  I tried casting it,
> which is legal, but it gives me funny characters.

> Thanks,
> Jim



Wed, 09 Feb 2005 00:46:03 GMT  
 Conversion Question
As usual...
Thanks Paul.



Quote:
> You are mixing Unicode strings, like that in the WIN32_FIND_DATA with
> single-byte character strings, as in the stringdata member.  You probably
> don't want to do that, anyway.  Use _tcscat(), not strcat(), and make
> stringdata an array of TCHAR, not char.

> Paul T.



> > Please help, I have the following code with the following error:

> > WIN32_FIND_DATA FileData;
> > char stringdata [8192];
> > ...
> > strcat(stringdata, FileData.cFileName);

> > error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned short
> > [260]' to 'const char *'

> > How can I concatenate the to the end of stringdata?  I tried casting it,
> > which is legal, but it gives me funny characters.

> > Thanks,
> > Jim



Wed, 09 Feb 2005 00:54:39 GMT  
 Conversion Question
Paul,
How do I change parameter 2 in this function then?

send(TempSock, stringdata, sizeof(stringdata), NULL);

I get the following error:
error C2664: 'send' : cannot convert parameter 2 from 'unsigned short
[8192]' to 'const char *'

Is there a way to convert back to 'const char *'?

Thanks,
Jim



Quote:
> You are mixing Unicode strings, like that in the WIN32_FIND_DATA with
> single-byte character strings, as in the stringdata member.  You probably
> don't want to do that, anyway.  Use _tcscat(), not strcat(), and make
> stringdata an array of TCHAR, not char.

> Paul T.



> > Please help, I have the following code with the following error:

> > WIN32_FIND_DATA FileData;
> > char stringdata [8192];
> > ...
> > strcat(stringdata, FileData.cFileName);

> > error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned short
> > [260]' to 'const char *'

> > How can I concatenate the to the end of stringdata?  I tried casting it,
> > which is legal, but it gives me funny characters.

> > Thanks,
> > Jim



Wed, 09 Feb 2005 01:01:26 GMT  
 Conversion Question
OK, if you're going to send it out over a socket, you'll have to convert the
Unicode string back to MBCS.  I prefer to use WideCharToMultiByte() for
that.

Paul T.


Quote:
> Paul,
> How do I change parameter 2 in this function then?

> send(TempSock, stringdata, sizeof(stringdata), NULL);

> I get the following error:
> error C2664: 'send' : cannot convert parameter 2 from 'unsigned short
> [8192]' to 'const char *'

> Is there a way to convert back to 'const char *'?

> Thanks,
> Jim



> > You are mixing Unicode strings, like that in the WIN32_FIND_DATA with
> > single-byte character strings, as in the stringdata member.  You
probably
> > don't want to do that, anyway.  Use _tcscat(), not strcat(), and make
> > stringdata an array of TCHAR, not char.

> > Paul T.



> > > Please help, I have the following code with the following error:

> > > WIN32_FIND_DATA FileData;
> > > char stringdata [8192];
> > > ...
> > > strcat(stringdata, FileData.cFileName);

> > > error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned
short
> > > [260]' to 'const char *'

> > > How can I concatenate the to the end of stringdata?  I tried casting
it,
> > > which is legal, but it gives me funny characters.

> > > Thanks,
> > > Jim



Wed, 09 Feb 2005 01:17:15 GMT  
 Conversion Question
Gotcha
Thanks again!


Quote:
> OK, if you're going to send it out over a socket, you'll have to convert
the
> Unicode string back to MBCS.  I prefer to use WideCharToMultiByte() for
> that.

> Paul T.



> > Paul,
> > How do I change parameter 2 in this function then?

> > send(TempSock, stringdata, sizeof(stringdata), NULL);

> > I get the following error:
> > error C2664: 'send' : cannot convert parameter 2 from 'unsigned short
> > [8192]' to 'const char *'

> > Is there a way to convert back to 'const char *'?

> > Thanks,
> > Jim



> > > You are mixing Unicode strings, like that in the WIN32_FIND_DATA with
> > > single-byte character strings, as in the stringdata member.  You
> probably
> > > don't want to do that, anyway.  Use _tcscat(), not strcat(), and make
> > > stringdata an array of TCHAR, not char.

> > > Paul T.



> > > > Please help, I have the following code with the following error:

> > > > WIN32_FIND_DATA FileData;
> > > > char stringdata [8192];
> > > > ...
> > > > strcat(stringdata, FileData.cFileName);

> > > > error C2664: 'strcat' : cannot convert parameter 2 from 'unsigned
> short
> > > > [260]' to 'const char *'

> > > > How can I concatenate the to the end of stringdata?  I tried casting
> it,
> > > > which is legal, but it gives me funny characters.

> > > > Thanks,
> > > > Jim



Wed, 09 Feb 2005 02:26:20 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ASCII to INT conversion question

2. fortran to C conversion questions

3. Conversion question for 32bit compilation

4. Type Conversion Question

5. BSTR, BYTE[ ] conversion question

6. Simple conversion question

7. Another conversion question

8. Newbie int to CString conversion question

9. type conversion question

10. CString conversion question

11. float to int conversion question

12. Newbie: datatype conversion question

 

 
Powered by phpBB® Forum Software