Message-Id: <199903150044.TAA23466@delorie.com> Comments: Authenticated sender is From: "George Foot" To: "Ron Higgins" Date: Mon, 15 Mar 1999 00:42:47 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Newbie Pointers CC: djgpp AT delorie DOT com X-mailer: Pegasus Mail for Win32 (v2.42a) Reply-To: djgpp AT delorie DOT com Firstly, your working program has a bug; the array is not large enough to hold the string. You allocated 16 characters, and filled them all with the string; there is no room for the terminating zero character. Never forget to allocate the extra space for this. More comments interspersed below. On 14 Mar 99 at 19:27, Ron Higgins wrote: > my mind is going along the lines : ptr1=ar1; > while (ptr1 > !=0(???)) You were told to `Use a separate integer variable to count the characters to print'. If you want to do it in the way that you have, you need to dereference since you actually want to look at the char pointed at, not the pointer itself. `while (*ptr1 != 0)', or just `while (*ptr1)'. > b) ptr1=ar1[15] Again you've got confused between the pointer and what it points at. Here you try to assign a char value (the 15th character) to a pointer. You want either: ptr1 = &ar1[15]; using the address operator to get the address of that object rather than its value, or more simply (and equivalently): ptr1 = ar1 + 15; which works because in this context `ar1' becomes a pointer to char. > while (ptr1 > !=something???) while (ptr1 >= ar1) ... but you were told to use an integer counter again. > I don't know whether I am miles away or close to solving the problem You're pretty close. I don't think this list/group is the right place for this question though; it is not specific to djgpp at all. -- George