Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Strange Behavior? Message-ID: <5668@goanna.cs.rmit.oz.au> Date: 9 May 91 09:23:33 GMT References: <1991May8.020720.20170@mccc.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 29 In article <1991May8.020720.20170@mccc.edu>, pjh@mccc.edu (Peter J. Holsberg) writes: > Here is an extract from a program a student wrote. Holsberg pointed out that a variable was declared char rather than int. In that program, on a little-endian machine, it will work; making the behaviour of longer and shorter integers consistent is what little-endian is _for_, after all. > #define MAX 9 > char sentence [MAX][SIZE]; /* an array of strings */ > printf("Input up to ten sentences \n"); There is a contradiction here. If sentence[] is to hold up to 10 sentences, MAX had better be 10, not 9! The input loop would be better as #define MAX 10 for (num = 0; num < 10 && gets(sentence[num]) != NULL && strcmp(sentence[num], "") != 0; num++) point[num] = original[num] = sentence[num]; Note: gets() has problems. Best to avoid it. See the FAQ. -- Bad things happen periodically, and they're going to happen to somebody. Why not you? -- John Allen Paulos.