2009/1/14 frano wrote: > > I have the following code: > > struct unit_struct { > unsigend char *version[LEN]; > ULONG board_id; > unsigned char *unit[LEN]; > }; > > > const unsigned long ud_brd_id = units_data->board_id; > XMLCh brd_id[100]; > XMLSize_t maxchars = sizeof(units_data->board_id); > const unsigned int rad = 10; > try { > XMLString::binToText(ud_brd_id, brd_id, maxchars, rad); > } catch (const XMLException& exc) { > cout << " Got exception \n"; > char *exc_msg = XMLString::transcode(exc.getMessage()); > cout << "Exception msg is " << exc_msg << "\n"; > } > > > When the code is executed I get a segmentation fault on the > XMLString::binToText call...... > > Any ideas of what I am doing wrong ? > > Fran >
You specify to the "binToText" function that the maximum number of characters the resulting string should be represented on is sizeof(ULONG) - which I assume is 4 or whatever number of bytes your system represents unsigned long on. I guess the number stored in "board_id" is represented on more digits than that, and it doesn't fit.