From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: I need help adressing characters in a string Date: Tue, 27 Apr 1999 14:32:26 -0300 Organization: BrunNet Lines: 33 Message-ID: <3725F4AA.D0B5BC60@unb.ca> References: <3725CBFE DOT AA56CB8F AT softhome DOT net> NNTP-Posting-Host: ftnts2c9.brunnet.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Chris Mears wrote: > > char string[100]; > > for (i = 0; i < sizeof (string) - 1; i++) > > In the for loop: i < sizeof (string)? Do you mean strlen() or > something else? If I recall correctly, sizeof returns the number of > bytes in a data type. So if string, in this case, is a constant pointer > to char, wouldn't it be 2 or 4 bytes, not the dynamic length of the > string? It's not a dynamic length. And 'string' isn't a simple pointer. Using sizeof on an array with a constant size will return the number of bytes in the array. char string[100]; char* a = string; sizeof(a); This will return 4, because 'a' is a (char *) and not an array. The real type of 'string' is (char [100]) it just casts to a (char *) without any warnings. -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT BrunNet DOT Net Endlisnis AT HotMail DOT com ICQ: 32959047