Click here to Skip to main content
15,896,063 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IXMLDOMDocument::loadXml question [modified] Pin
YaronNir29-May-06 20:02
YaronNir29-May-06 20:02 
GeneralRe: IXMLDOMDocument::loadXml question [modified] Pin
_anil_29-May-06 20:07
_anil_29-May-06 20:07 
GeneralRe: IXMLDOMDocument::loadXml question [modified] Pin
YaronNir29-May-06 20:26
YaronNir29-May-06 20:26 
GeneralRe: IXMLDOMDocument::loadXml question [modified] Pin
_anil_29-May-06 20:48
_anil_29-May-06 20:48 
GeneralRe: IXMLDOMDocument::loadXml question Pin
ThatsAlok30-May-06 1:35
ThatsAlok30-May-06 1:35 
AnswerRe: IXMLDOMDocument::loadXml question Pin
bob1697229-May-06 16:03
bob1697229-May-06 16:03 
GeneralRe: IXMLDOMDocument::loadXml question Pin
YaronNir29-May-06 20:01
YaronNir29-May-06 20:01 
QuestionWriting null character to a file Pin
fourierman29-May-06 10:48
fourierman29-May-06 10:48 
Regarding the null terminating character being embedded within a source/custom resource (input string) , I'm having some difficulty getting fwrite to continue past embedded 0x00 values in my data...

Someone posted elsewhere on this site:
It acted like it continued beyond the end of the array until it came across the zero byte in memory. I put the "\0" or the 0x00 and it stopped exactly where I told it too. This raises the question, if that array is supposedly a hex representation of an exe, how are you getting away without stumbling across 0x00 somewhere in the binary string? this is one of the reason they tell us to encode binary data when using a null terminated string to contain it.

My code:

CODE
char * cStr = reinterpret_cast< char *>(lpVoid);
cStr = strncat(cStr, "\0", 1);
printf("size of cStr%d\n", sizeof(cStr));
FILE * stream;
if( (stream = fopen( "fread.out", "w" )) != NULL )
{
int num_write = 0;
num_write = fwrite( cStr, sizeof( cStr ), 1, stream );
printf( "Wrote items: %d\n", num_write );
fclose( stream );
}
Results:

follwing were writing sizeof(cStr) - 1 (not wanting to write the trailing null to our output file):

testing: 4d 5a 90 as input, output: 4d 5a 90 (OK)
testing: 4d 5a 90 00 as input, output: 4d 5a 90
testing: 4d 5a 90 00 03 as input, output: 4d 5a 90
testing: 4d 5a 90 03 as input: output: 4d 5a 90

writing sizeof(cStr) :
4d 5a 90 -> 4d 5a 90 00
4d 5a 90 00 -> 4d 5a 90 00
4d 5a 90 00 03 -> 4d 5a 90 00 (stripped trailing character)

Anyone have any suggestions on how to proceed?
How will the program know the difference between the trailing null at the end of the string versus embedded nulls?
AnswerRe: Writing null character to a file Pin
Michael Dunn29-May-06 11:05
sitebuilderMichael Dunn29-May-06 11:05 
AnswerRe: Writing null character to a file Pin
bob1697229-May-06 14:03
bob1697229-May-06 14:03 
Question[Message Deleted] Pin
Rudy10229-May-06 9:22
Rudy10229-May-06 9:22 
AnswerRe: Save C++ Object to XML / Load XML data to C++ Pin
Maximilien29-May-06 10:15
Maximilien29-May-06 10:15 
AnswerRe: Save C++ Object to XML / Load XML data to C++ Pin
Eytukan29-May-06 15:52
Eytukan29-May-06 15:52 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
Rudy10229-May-06 19:45
Rudy10229-May-06 19:45 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
toxcct29-May-06 22:01
toxcct29-May-06 22:01 
GeneralRe: Save C++ Object to XML / Load XML data to C++ [modified] Pin
Rudy10230-May-06 3:45
Rudy10230-May-06 3:45 
QuestionMapi library error Pin
Javielgrande29-May-06 9:14
Javielgrande29-May-06 9:14 
QuestionSingletone Design Pattern Pin
knoxplusplus29-May-06 7:54
knoxplusplus29-May-06 7:54 
AnswerRe: Singletone Design Pattern Pin
Cedric Moonen29-May-06 8:16
Cedric Moonen29-May-06 8:16 
AnswerRe: Singletone Design Pattern Pin
G Haranadh29-May-06 18:15
G Haranadh29-May-06 18:15 
GeneralRe: Singletone Design Pattern Pin
BadKarma29-May-06 20:32
BadKarma29-May-06 20:32 
GeneralRe: Singletone Design Pattern Pin
G Haranadh29-May-06 22:47
G Haranadh29-May-06 22:47 
GeneralRe: Singletone Design Pattern Pin
knoxplusplus30-May-06 7:36
knoxplusplus30-May-06 7:36 
GeneralRe: Singletone Design Pattern Pin
G Haranadh30-May-06 7:45
G Haranadh30-May-06 7:45 
QuestionCImage linker problems. Please help! Pin
Rostfrei29-May-06 7:53
Rostfrei29-May-06 7:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.