www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/16/14:51:17

From: Elliott Oti <e DOT oti AT stud DOT warande DOT ruu DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Q: Typedef riddle
Date: Sat, 16 Nov 1996 06:44:01 -0800
Organization: Academic Computer Centre Utrecht, (ACCU)
Lines: 40
Message-ID: <328DD331.26E4@stud.warande.ruu.nl>
NNTP-Posting-Host: warande1078.warande.ruu.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
I've been programming in C for a couple of years now and I thought
I knew at least the basics pretty well, but this has me stumped.

Why does the following short little program output

     10 <rubbish> <rubbish>
     It's also 10 10 10

instead of  
  
     10 10 10
     It's also 10 10 10 

It's not a gcc bug because Borland gives a similar output,
but -Wall gives absolutely no warnings. So what's wrong?

TIA,
Elliott

--------------------- SNIP ------------------------------------------
#include <stdio.h>

typedef int thing[3];

void Dump(thing *V)
{
printf("\n%i %i %i\n",*V[0],*V[1],*V[2]);
}

int main(void)
{
thing V;
V[0] = V[1] = V[2] = 10;
Dump(&V);
printf("\nIt's also %i %i %i\n",V[0],V[1],V[2]);
return 0;
}

-------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019