Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: tlug: gcc question
- To: tlug@example.com
- Subject: Re: tlug: gcc question
- From: "Scott M. Stone" <sstone@example.com>
- Date: Wed, 12 Jan 2000 15:50:21 -0800 (PST)
- Content-Type: TEXT/PLAIN; charset=US-ASCII
- In-Reply-To: <387CFBBB.B2E37BBD@example.com>
- Reply-To: tlug@example.com
- Sender: owner-tlug@example.com
On Wed, 12 Jan 2000, Fredric Fredricson wrote: > I would say this question is more appropriate on a c mailing > list or news group but I will try to answer it anyway: > > Your code is broken in a way that will show up differently on > different OSes. > > "Drew C. Poulin" wrote: > > > > #include<stdio.h> > > > > main(){ > > > > char *fname, *lname; > Defines two pointers to char arrays. Usually the pointers are > initialized to 0x0000, but you can never be sure.... I don't think that gcc/egcs will make programs this way -- every time I've debugged a program, I've never seen them initialized to NULL - doesn't mean it doesn't happen sometimes, I've just never seen it... always initialize your own pointers :) > It is also important to remember that there is no > built in bounds checking in c arrays. None. At all. > C is difficult for a beginner since it is essentially > a more or less portable assembler on steroids. therefore, never use gets() - if I do: char *foo; foo=(char *)malloc(80); /* (or do char foo[80];) */ memset(foo,0,80); /* zeroes out the string */ gets(foo); and i type in 100 characters -- then what? SIGSEGV, that's right. called a buffer overrun. HOWEVER: fgets(foo,79,stdin); will do the bounds checking for you. -------------------------- Scott M. Stone, CCNA <sstone@example.com> UNIX Systems and Network Engineer Taos - The SysAdmin Company ------------------------------------------------------------------- Next Technical Meeting: January 14 (Fri) 19:00 * Topic: "glibc - current status and future developments" * Guest Speaker: Ulrich Drepper (Cygnus Solutions) * Place: Oracle Japan HQ 12F Seminar Room (New Otani Garden Court) ------------------------------------------------------------------- more info: http://www.tlug.gr.jp Sponsor: Global Online Japan
- Follow-Ups:
- Re: tlug: gcc question
- From: Fredric Fredricson <Fredric.Fredriksson@example.com>
- References:
- Re: tlug: gcc question
- From: Fredric Fredricson <fredric.fredriksson@example.com>
Home | Main Index | Thread Index
- Prev by Date: Re: tlug: gcc question
- Next by Date: Re: tlug: gcc question
- Prev by thread: Re: tlug: gcc question
- Next by thread: Re: tlug: gcc question
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links