Tony Murphy wrote:[color=blue]
>
> 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[/color]
This means (and I think you have already recognized it), that there
is a '\0' character somewhere within.
[color=blue]
>
> 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?[/color]
You mean the string you got by reading the file.
eg. by checking each byte.
ask the string about it's size :-)
for ( i = 0; i < MyString.size(); ++i )
if( MyString[i] == '\0' )
cout << "There is a 0 at position " << MyString[i] << endl;
--
Karl Heinz Buchegger
kbuchegg@gascad.at