| ||||||||
Technical Support Support Resources Product Information | C166: SPRINTF AND FAR STRINGSInformation in this article applies to:
QUESTIONIn C166, I'm using sprintf to get formatted data into a far array of characters. My question is: Is it valid to pass strings that exist in far memory to sprintf as shown here? #define achBuffer XARRAY ( char, 0x100000 ) sprintf( achBuffer, "%d", 1 ); If yes, which memory models (other than TINY) is it not valid for? ANSWERYes. This is valid. In the C166, the following memory models, by default, assume that variables are of the indicated types. Memory Model Variable Memory --------------------------------- TINY near SMALL near COMPACT far HCOMPACT huge MEDIUM near LARGE far HLARGE huge --------------------------------- In COMPACT and LARGE memory models, sprintf assumes that the buffer is in far memory (and a far pointer is needed). Since a far pointer can be converted into a huge pointer, HCOMPACT and HLARGE models will also work for your example (because far pointers can be converted into huge pointers). MEDIUM, SMALL, and TINY models will not work (unless you luck out and the far memory is in the same space as the near memory). MORE INFORMATION
Last Reviewed: Friday, July 15, 2005 | |||||||
| ||||||||