LiquidBinary
Programmer
#include <string>
#include <iostream>
using namespace std;
char *String_Convert( const string &sConvert,
char *cString );
int main()
{
string sTest = "Convert C++ string to C string.";
char *cTest = 0;
cTest = String_Convert( sTest,cTest );
cout << cTest;
delete [] cTest;
return 0;
}
char *String_Convert( const string &sConvert,char *cString )
{
int iSizeOfString = sConvert.length();
cString = new char[iSizeOfString+1];
for ( int i=0;i<iSizeOfString;i++ )
cString = sConvert;
cString = '\0';
return cString;
} Mike L.G.
mlg400@blazemail.com
#include <iostream>
using namespace std;
char *String_Convert( const string &sConvert,
char *cString );
int main()
{
string sTest = "Convert C++ string to C string.";
char *cTest = 0;
cTest = String_Convert( sTest,cTest );
cout << cTest;
delete [] cTest;
return 0;
}
char *String_Convert( const string &sConvert,char *cString )
{
int iSizeOfString = sConvert.length();
cString = new char[iSizeOfString+1];
for ( int i=0;i<iSizeOfString;i++ )
cString = sConvert;
cString = '\0';
return cString;
} Mike L.G.
mlg400@blazemail.com