T
Tony Murphy
I've got an application that sends emails (not spam!). The application
reads a template file (html/text) into a string, the string is
processed and placeholders filled in as appropiate.
I call a 3rd party api for sending the email, the api is written in c,
so i need to convert the string into LPSTR (windows c style string?),
i'm from unix world and new to windows mutant.
I know that c_str() converts a string to a c string and data() writes
the characters of a string into an array and isn't necessarily null
terminated.
I use printf to see whats been sent to a user, printf("%s",x.c_str())
& printf("%s",x.data()), but both only print out part of the string
cout << " SENDING HTML EMAIL " << x << endl; works file and prints out
the entire string
the 3rd party application fortunately sends the email in full. but i
need to know why only part of the string is been seen by printf.
How can i check if a file contains a null terminating character? I've
tried printing out a hex dump of the string using the following
method, but it doesn't get to the end of the string either
void dumpHex(const string &stringToHex)
{
ostringstream os;
string::const_iterator i = stringToHex.begin();
string::const_iterator e = stringToHex.end();
while (i!=e) {
os << std::hex << static_cast<string::traits_type::int_type>(*i++)
<< " " << *i << " ";
}
os << ends;
printf("HEX DUMP: \n\n%s\n\n",os.str().c_str());
}
this problem is driving me mad. i've trawled this news group looking
for answers cause there nearly always something similar unless i'm
doing something very stupid and nobody else stupid enough has bothered
to post about something similar. i'm going round in circles.
reads a template file (html/text) into a string, the string is
processed and placeholders filled in as appropiate.
I call a 3rd party api for sending the email, the api is written in c,
so i need to convert the string into LPSTR (windows c style string?),
i'm from unix world and new to windows mutant.
I know that c_str() converts a string to a c string and data() writes
the characters of a string into an array and isn't necessarily null
terminated.
I use printf to see whats been sent to a user, printf("%s",x.c_str())
& printf("%s",x.data()), but both only print out part of the string
cout << " SENDING HTML EMAIL " << x << endl; works file and prints out
the entire string
the 3rd party application fortunately sends the email in full. but i
need to know why only part of the string is been seen by printf.
How can i check if a file contains a null terminating character? I've
tried printing out a hex dump of the string using the following
method, but it doesn't get to the end of the string either
void dumpHex(const string &stringToHex)
{
ostringstream os;
string::const_iterator i = stringToHex.begin();
string::const_iterator e = stringToHex.end();
while (i!=e) {
os << std::hex << static_cast<string::traits_type::int_type>(*i++)
<< " " << *i << " ";
}
os << ends;
printf("HEX DUMP: \n\n%s\n\n",os.str().c_str());
}
this problem is driving me mad. i've trawled this news group looking
for answers cause there nearly always something similar unless i'm
doing something very stupid and nobody else stupid enough has bothered
to post about something similar. i'm going round in circles.