Mail Archives: djgpp/1999/09/01/19:42:40
On Wed, 1 Sep 1999 14:40:23 +0300 (IDT), Eli wrote:
> [snip]
>> /* Define the structure used for holding information about a video mode */
>> typedef struct {
>> char name[64]; /* Identification string */
>> u_shortint width; /* Width (in pixels) */
>
> The member `width' is declared 16-bit unsigned short, but you read it
> with a format specifier that tells sscanf its a 32-bit unsigned int.
> Therefore, sscanf will corrupt the previous member. (You might get away
> with some of the members because GCC aligns struct members for optimum
> performance, but that's sheer luck.)
>
> The same is true for all the other members.
>
> To read a short, use %hd or %hX, as the case may be.
Thanks. However, I tried the '%hd' and '%hX', but to no avail. The new code
I used is that given below:
sscanf(modedef, "%[^:]:%hdx%hd:%hd:%hd:%hX:%hX:%hX",
mode->name,
&mode->width,
&mode->height,
&mode->depth,
&mode->flags,
&seg,
&off,
&mode->num);
But it still doesn't work. I even tried using '%[^:]:%hd x%hd' for the first
part (notice the extra space) because I thought that 'sscanf()' might be
trying to interpret the 'x' (which is part of my 'modedef' syntax) as a hex
type-specifier. The thing is, the code works fine in Linux, which is usually
the first to complain if there's a segmentation violation or something. I'm
stuck :( Thanks,
Pete =:-)
--
/*************** [burdock] ****************/
/* ____/| pete AT restall DOT net */
/* \ o.O| http://www.iirc.net/petes/ */
/* =(_)= */
/* U */
/******************************************/
/******************************* [Windoze 98] ********************************/
/* Windows 98: n. (Alex Satrapa). */
/* 64 bits (and pieces) of bugs (and fixes) and featuritis tacked on to 32 */
/* bit extensions and a graphical shell for a 16 bit patch to an 8 bit */
/* operating system originally coded for a 4 bit microprocessor, written */
/* by a 2 bit company that can't stand 1 bit of competition, and has not a */
/* bit of respect for their customers. */
/*****************************************************************************/
- Raw text -