X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Message-ID: <20011221201436.94468.qmail@web13902.mail.yahoo.com> Date: Fri, 21 Dec 2001 12:14:36 -0800 (PST) From: Chris Amos Subject: Re: *Newbie= Why isn't this small function working correctly? To: djgpp AT delorie DOT com In-Reply-To: <20011218200551.38218.qmail@web13907.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk // There was also another thing wrong that I missed void getstr(const char *string, char *new_string, int start_offset, int end_offset) { int i=0; int b=0; for (i=start_offset; i<=end_offset; i++) { // *(new_string+b)=string+i; // this is assigning the pointers to a char array instead of chars // It should be: *(new_string+b)=*(string+i) b++; } *(new_string+b)='\0'; return; } // This is untested but i think it works fine for any other newbies // that are interested in the code P.S. Sorry for the off-topic thread DJ. --- Chris Amos wrote: > It has to be a logic error of some kind because the code runs fine > aside from a few warning messages... > > ----------------------------------------------------------------------- > > /* This is a memmory string cut function. > *string = pointer to the string were cutting from > *new_string = pointer to the memmory where the 'cut' string will > go > start_offset = Where we will start cutting >= 0 > end_offset = Where we will stop cutting >= start_offset > > */ > void getstr(const char *string, const char *new_string, int > start_offset, int end_offset); > > /**************************************************************************/ > void getstr(const char *string, const char *new_string, int > start_offset, int end_offset) > { > int i=0; > int b=0; > > for (i=start_offset; i<=end_offset; i++) { > *(new_string+b)=string+i; > b++; > } > *(new_string+b)='\0'; > return; > } > > ===== > ~ Twisted Matrix (Founder of ULTRATECH) > > URL: N/A > ICQ: 74628745 > > __________________________________________________ > Do You Yahoo!? > Check out Yahoo! Shopping and Yahoo! Auctions for all of > your unique holiday gifts! Buy at http://shopping.yahoo.com > or bid at http://auctions.yahoo.com ===== ~ Twisted Matrix aka. Christoph A. Amos ~ URL: http://qbrpg.qb45.com ICQ: 74628745 *Not active right now __________________________________________________ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com