From: "A.Appleyard" To: djgpp AT sun DOT soe DOT clarkson DOT edu Date: Mon, 11 Dec 1995 09:02:34 GMT Subject: Re: wierd "bug" in my program? aue AT u DOT washington DOT edu (A. Aue) wrote (Subject: wierd "bug" in my program?):- > Help! I'm having a really strange problem with the bridge program I'm > writing under djgpp ... ELEMENTARY!!!!!! Most of the times when he has declared an array x[n], he runs the array subscripts from x[1] to x[n]. This is OK for Fortran, but WRONG!!! for C and C++. If a C or C++ array is declared say x[n], the valid elements of x run from x[0] to x[n-1] !!!!! #include #include #include typedef struct hand {char name[30]; int cards[13],clubs[13],diamonds[13], hearts[13],spades[13],numclubs,numdiamonds,numhearts,numspades,hcp,dp,tp, turn,bid; } Hand; /*-----*/ main() { Hand hands[4]; int n; void initialize (Hand[]); void deal (Hand[]); printf("begin main"); initialize (hands); deal (hands); printf("hello."); for (n=1; n<=13; ++n) printf("South %d west %d north %d east %d\n", hands[1].cards[n], hands[2].cards[n], hands[3].cards[n], hands[4].cards[n]); printf("end main."); } ...