A c programming question?

2003-07-30 Thread reza saeidinia
Hello .
whats the following messages mean:
/usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o In function ''_start':
/usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o(.text+ox18):undefined refrence to 'main'
thank you.

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Re: A c programming question?

2003-07-30 Thread fred smith
On Wed, Jul 30, 2003 at 01:11:23AM -0700, reza saeidinia wrote:
 Hello .
 whats the following messages mean:
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o In  function ''_start':
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o(.text+ox18):undefined refrence to 
 'main'
 thank you.

it means that the linker couldn't find any function named main()
in your program. 

-- 
---
 .Fred Smith/  
( /__  ,__.   __   __ /  __   : / 
 //  /   /__) /  /  /__) .+'   Home: [EMAIL PROTECTED] 
//  (__ (___ (__(_ (___ / :__ 781-438-5471 
 Jude 1:24,25 -


pgp0.pgp
Description: PGP signature


Re: A c programming question?

2003-07-30 Thread mark
On Wednesday 30 July 2003 06:00 am, 
 From: reza saeidinia [EMAIL PROTECTED]

 whats the following messages mean:
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o In  function ''_start':
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o(.text+ox18):undefined
 refrence to 'main' thank you.

That you're trying to compile a program that has no function named main. Try 
reading the book (any book, though I prefer KR), and you'll see that every 
executable C program *REQUIRES* that the top, first function that is 
executed when the program runs, and which runs everything else, be named 
main.

RTFM

mark 

-- 
Message to Ashcroft:
Necessity is the plea for every infringement of human freedom. It is the 
argument of tyrants; it is the creed of slaves. William Pitt, 1783 



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: A c programming question?

2003-07-30 Thread Wartnick, James
This can also occur when you don't compile the program correctly. The first 
response is correct: 
there is no main function inside the program crt1.o. However, if crt1 is never 
meant to be a program 
(examples would be an object file or library.), then you are fine and can 
ignore the message.

For example, let's say I am creating an object file (sometimes can be referred 
to as a library). The object file contains popular functions that many of my other 
programs use (let's say the object file is called: my_math_routines). In 
my_math_routines source code I would have functions 
like Add , Subtract, etc.. my_math_routines will never run as a 
stand-alone program (by itself). 
However, other programs will call some of these functions (e.g. myprogram.c). 
Therefor what I would 
do is the following:

1) Compile my_math_routines.c into an object file (make math_routines.o)
2) Compile myprogram.c and link in my_math_routines.o

If in step 1 I did a make math_routines (notice how I left out the .o), it 
would actually try to create a 
standalone program called my_math_routines. However, since this program does 
not have a main 
function (as stated in the e-mail below), I would receive the error you saw 
(main not defined in). 
However, I know that that message is OK since I don't want a math_routines 
program (just a mistake 
in my part when I ran the make command in step 1.

Hope this is not too confusing and somewhat helpful.

-Jim

--

Message: 8
From: mark [EMAIL PROTECTED]
Organization: 24.5 Century Productions, unLtd.
To: [EMAIL PROTECTED]
Subject: Re: A c programming question?
Date: Wed, 30 Jul 2003 09:16:57 -0400
Reply-To: [EMAIL PROTECTED]

On Wednesday 30 July 2003 06:00 am, 
 From: reza saeidinia [EMAIL PROTECTED]

 whats the following messages mean:
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o In  function ''_start':
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o(.text+ox18):undefined
 refrence to 'main' thank you.

That you're trying to compile a program that has no function named main. Try 
reading the book (any book, though I prefer KR), and you'll see that every 
executable C program *REQUIRES* that the top, first function that is 
executed when the program runs, and which runs everything else, be named 
main.

RTFM

mark 



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


Re: A c programming question?

2003-07-30 Thread Jonathan Bartlett
It means you forgot to include a main function - that's where the
program starts.  Let me know if you need more help.

This can happen if you forget to specify '-c' when compiling source files
individually.

Jon

On Wed, 30 Jul 2003, reza saeidinia wrote:

 Hello .
 whats the following messages mean:
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o In  function ''_start':
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/crt1.o(.text+ox18):undefined refrence to 
 'main'
 thank you.



 -
 Do you Yahoo!?
 Yahoo! SiteBuilder - Free, easy-to-use web site design software


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list


newbie C programming question

2003-01-02 Thread Christopher Henderson
I'm trying to teach myself C and I'm having trouble compiling my first
program.  This is following the C Tutorial at
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html.

My first program, a simple Hello World, is as follows

#include  stdio.h

void main()
{
printf(\nHello World\n);
}

I go to a console and type gcc hello.c as stated in the tutorial and get 
the following error spit out at me -

hello.c:1:20:  stdio.h: No such file or directory
hello.c: In function `main':
hello.c:4: warning: return type of `main' is not `int'

well, I did a whereis on stdio.h and its in /usr/include - any ideas on the 
problem?  I know this might be a bit off-topic, and btw I'm running RH 8.

Thnx folks,
~Christopher



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list



Re: newbie C programming question

2003-01-02 Thread Willem Brown
Christopher Henderson wrote:

I'm trying to teach myself C and I'm having trouble compiling my first
program.  This is following the C Tutorial at
http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html.

My first program, a simple Hello World, is as follows

#include  stdio.h


Remove the space character between the  and stdio and try again.



void main()
{
printf(\nHello World\n);
}

I go to a console and type gcc hello.c as stated in the tutorial and get 
the following error spit out at me -

hello.c:1:20:  stdio.h: No such file or directory
hello.c: In function `main':
hello.c:4: warning: return type of `main' is not `int'

well, I did a whereis on stdio.h and its in /usr/include - any ideas on the 
problem?  I know this might be a bit off-topic, and btw I'm running RH 8.

Thnx folks,
~Christopher




Also, gcc hello.c will generate an executable called a.out. If you want
the executable to be called hello you should use gcc -o hello hello.c
instead.

To execute you would type ./hello and press the enter key.

Best Regards
Willem Brown

--
iServe (Pty) Ltd.
http://www.iserve.co.za/

Tel: +27 (0)11 258-7800
Fax: +27 (0)11 258-7888
Cell: +27 (0)83 271-0839



--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list



Re: newbie C programming question

2003-01-02 Thread Gordon Messmer
On Thu, 2003-01-02 at 00:18, Christopher Henderson wrote:
 My first program, a simple Hello World, is as follows
 
 #include  stdio.h
 
 void main()
 {
 printf(\nHello World\n);
 }
 
 I go to a console and type gcc hello.c as stated in the tutorial and get 
 the following error spit out at me -
 
 hello.c:1:20:  stdio.h: No such file or directory

Remove the space before the header name.

 hello.c: In function `main':
 hello.c:4: warning: return type of `main' is not `int'

The C standard requires that the return type of the main function be
int, not void.  Your main function should always be declared:

int main( int argc, char ** argv )
or, equivalently:
int main( int argc, char * argv[] )




-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list



Re: newbie C programming question

2003-01-02 Thread Christopher Henderson
That did it - thnx!

~Christopher

On Thu, 2003-01-02 at 02:38, Willem Brown wrote:
 Christopher Henderson wrote:
  I'm trying to teach myself C and I'm having trouble compiling my first
  program.  This is following the C Tutorial at
  http://www.physics.drexel.edu/courses/Comp_Phys/General/C_basics/c_tutorial.html.
  
  My first program, a simple Hello World, is as follows
  
  #include  stdio.h
 
 Remove the space character between the  and stdio and try again.
 
  
  void main()
  {
  printf(\nHello World\n);
  }
  
  I go to a console and type gcc hello.c as stated in the tutorial and get 
  the following error spit out at me -
  
  hello.c:1:20:  stdio.h: No such file or directory
  hello.c: In function `main':
  hello.c:4: warning: return type of `main' is not `int'
  
  well, I did a whereis on stdio.h and its in /usr/include - any ideas on the 
  problem?  I know this might be a bit off-topic, and btw I'm running RH 8.
  
  Thnx folks,
  ~Christopher
  
  
  
 
 Also, gcc hello.c will generate an executable called a.out. If you want
 the executable to be called hello you should use gcc -o hello hello.c
 instead.
 
 To execute you would type ./hello and press the enter key.
 
 Best Regards
 Willem Brown
 
 -- 
 iServe (Pty) Ltd.
 http://www.iserve.co.za/
 
 Tel: +27 (0)11 258-7800
 Fax: +27 (0)11 258-7888
 Cell: +27 (0)83 271-0839
 
 



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list



Re: c programming question - regexec related

2001-01-11 Thread Bruce A. Mallett

Some of my programs use regcomp/regexec on RH7 and I've not seen a
problem.  Memory problems can be most insidious .. you might want to
compile against something like efence or (if you've the luxury of a platform
supporting it), Purify.

- Bruce


Rick Forrister wrote:

 Am having a problem with a regcomp/regex expression in a program I'm
 working on; one of the compiled regex_t structs appears to become
 corrupted after about 3 calls to regexec.  Which leads to a crash of
 the program.

 Wondering if anyone else has seen this behaviour; it's occuring on
 RH 7.0 with both the 2.95  2.96 gcc compilers.  The temporary
 workaround, of course, is to call regcomp each time regexec is
 called.  Seems a bit much.

 basically the code is:

 regex_t HEADER;

 rtn = regcomp(HEADER, reg_expression_string, REG_EXTENDED);

 if (regexec(HEADER, Line, 0, REG_NOTEOL) == REG_NOMATCH){ ... }

 and looking at the address field in HEADER shows that for the first
 three calls the address is valid.  After the third call, the address
 field is corrupted.  No other areas of the code access that regex_t
 struct or reference it in any way.

 best
  rickf

 Rick Forrister [EMAIL PROTECTED]

 Definition:  Honest Politician:  Once bought, stays bought."
 --Robert Heinlein

 ___
 Redhat-list mailing list
 [EMAIL PROTECTED]
 https://listman.redhat.com/mailman/listinfo/redhat-list



___
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list



Re: C programming question...[OT]

2000-05-08 Thread Neil Hollow

Can anyone recommend a good c programming newsgroup for general questions
and queries.  NH
--
From: Sam Bayne [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: C programming question...[OT]
Date: Fri, May 5, 2000, 3:42 am


First of all, thank everyone for helping me out with idiotic basic
questions.

Gordon Messmer wrote:
 
 1)  No, the programmers declared an array of 5 character pointers, not
 an array of 5 characters.  Perl 5 doesn't have pointers, so I understand
 your confusion  :) They're one of the things that non-C programmers
 bitch about.  (If you don't understand pointers, using them is a quick
 way to a segfault).

Hee hee, perl doesn't have pointers, but it DOES have references. (But
they have some idiot protections WRT segfault.) The thing that is really
confusing about C's pointers is not the "they're memory locations"
thing,
it's the way they get shuffled back and forth with pointer or array
notation at the programmer's whim. 
 
 2)  Yes, it's a list of up to five acceptable directories (or so it
 appears).  The maximum size of each of these is not defined, but will be
 the maximum size of a command line argument.  A pointer is an address in
 memory.  Every program is passed two arguments to its main() function,
 an int and an array of character pointers.  The programmers of tftpd are
 setting each of the pointers in their array to one of the arguments (if
 there are any arguments).  By doing this, they reduce the risk of a
 buffer overflow by not copying their command line arguments into static
 buffers.  They simply point their variables at the arguments already in
 memory, rather than duplicate them.

Ok, that was the actual question I was dancing around, so the
commandline
parser( I assume one of exec()'s brethren, whatever inetd is using) is
responsible for bounds checking these then?

 
 3)  Syntactically, the while loop is valid.  Style is quite left up to
 the programmer.  If you feel like writing code that looks like Perl, you
 can  :)
 (I usually code fairly close to the GNU style guides)

I'm going to look those up right quick.

-- 
-
Sam Bayne - System Administrator
North Seattle Community College
[EMAIL PROTECTED] (206)527-3762
=


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-05 Thread Ken Gosier


--- Steve Borho [EMAIL PROTECTED] wrote:
 Speaking to just pure style, though, that while loop
 reminds me of the
 most efficient C snippet I've ever seen.  It's the
 standard implementation
 of strcpy.
 
 for (;*s;)
   *d++ = *s++;


One question about this code snippet: Won't it fail to copy
the terminating '\0' into the target string?

=
Ken Gosier
[EMAIL PROTECTED]

__
Do You Yahoo!?
Send instant messages  get email alerts with Yahoo! Messenger.
http://im.yahoo.com/


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




RE: C programming question...[OT]

2000-05-05 Thread Mike McNally

 --- Steve Borho [EMAIL PROTECTED] wrote:
  Speaking to just pure style, though, that while loop
  reminds me of the
  most efficient C snippet I've ever seen.  It's the
  standard implementation
  of strcpy.
  
  for (;*s;)
*d++ = *s++;
 
 
 One question about this code snippet: Won't it fail to copy
 the terminating '\0' into the target string?

Well, first, it's not really what I'd consider the classic
strcpy:

while (*d++ = *s++);

That one will copy the null on the last iteration (the one
that fails the test).

Mike McNally | Turtle, turtle, on the ground,
[EMAIL PROTECTED] | Pink and shiny, turn around.
 


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-05 Thread rpjday

On Fri, 5 May 2000, Ken Gosier wrote:

 
 --- Steve Borho [EMAIL PROTECTED] wrote:
  Speaking to just pure style, though, that while loop
  reminds me of the
  most efficient C snippet I've ever seen.  It's the
  standard implementation
  of strcpy.
  
  for (;*s;)
*d++ = *s++;
 
 
 One question about this code snippet: Won't it fail to copy
 the terminating '\0' into the target string?

while (*d++ = *s++) ;

  or something to that effect, as i recall.

rday


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-05 Thread Steve Borho

On Fri, May 05, 2000 at 01:24:30PM -0400, rpjday wrote:
 On Fri, 5 May 2000, Ken Gosier wrote:
 
  
  --- Steve Borho [EMAIL PROTECTED] wrote:
   Speaking to just pure style, though, that while loop
   reminds me of the
   most efficient C snippet I've ever seen.  It's the
   standard implementation
   of strcpy.
   
   for (;*s;)
 *d++ = *s++;
  
  
  One question about this code snippet: Won't it fail to copy
  the terminating '\0' into the target string?
 
 while (*d++ = *s++) ;
 
   or something to that effect, as i recall.

Yeah, this is correct.  I shouldn't have written that code snippet without
my recommended daily allowance of coffee.

-- 
Steve Borho   Voice:  314-615-6349
Network Engineer
Celox Networking Inc

Fortune of the day:
The avoidance of taxes is the only intellectual pursuit that carries any
reward.
-- John Maynard Keynes


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-05 Thread Gordon Messmer

Sam Bayne wrote:
 Hee hee, perl doesn't have pointers, but it DOES have references.

Really?  I thought those were new in Perl 5.6.

 they have some idiot protections WRT segfault.) The thing that is really
 confusing about C's pointers is not the "they're memory locations"
 thing,
 it's the way they get shuffled back and forth with pointer or array
 notation at the programmer's whim.

Just tell yourself that "There's more than one way to do it"!  :)

 Ok, that was the actual question I was dancing around, so the
 commandline
 parser( I assume one of exec()'s brethren, whatever inetd is using) is
 responsible for bounds checking these then?

Honestly don't know.  I suspect that it's a kernel limitation.


MSG


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-04 Thread Steve Borho

On Thu, May 04, 2000 at 05:23:37PM -0700, Sam Bayne wrote:
 So There I am, rooting around in the source to the tftpd server
 (never you mind why) when I see this:
 
 -
 #define MAXARG  4
 static char *dirs[MAXARG+1];
  
 int
 main(int ac, char **av)
 {
 register struct tftphdr *tp;
 register int n = 0;
 int on = 1;
  
 ac--; av++;
 if (ac==0) dirs[0] = "/tftpboot";  /* default directory */
 while (ac--  0  n  MAXARG)
 dirs[n++] = *av++; 
 -
 
 There are several things about this code that puzzle me.
 
 1.  It looks to me like 'dirs' is set to be a 5 character
   string by the MAXARG define, then they turn around
   and set a default of 9 characters? Didn't they just
   run right off the end of the array?

static char *dirs[MAXARG+1];

This is an array of 5 character pointers.

 2. Or am I misreading this and it's creating a list of up to
   5 acceptable directories? If that's so, where does it set
   the maximum size for each argument? If that's in some
   previous part of the declarations, that's fine, just
   give me an example construction to look for.

There is no length.  He's assigining string pointers to string pointers.
(one is a ptr to a string constant, the others are string pointers passed
to you by the execve function *otherwise known as command line arguments*)

 3. Stylistically, is that 'while' statement normal? It looks to
   me like a syntax mistake waiting to happen, but I'll code
   to that style if it's normal for C programmers. Coming
   from a mostly perl background that line would either be
   one line or enclosed in curly braces.

It's not something I would write, but it's acceptable.  If you can't
understand what it does in under 10 seconds, then it's a safe bet you
shouldn't write it that way for your own sake, much less anyone else's.

-- 
Steve Borho   Voice:  314-615-6349
Network Engineer
Celox Networking Inc

Fortune of the day:
I use not only all the brains I have, but all those I can borrow as well.
-- Woodrow Wilson


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-04 Thread Gordon Messmer

1)  No, the programmers declared an array of 5 character pointers, not
an array of 5 characters.  Perl 5 doesn't have pointers, so I understand
your confusion  :) They're one of the things that non-C programmers
bitch about.  (If you don't understand pointers, using them is a quick
way to a segfault).

2)  Yes, it's a list of up to five acceptable directories (or so it
appears).  The maximum size of each of these is not defined, but will be
the maximum size of a command line argument.  A pointer is an address in
memory.  Every program is passed two arguments to its main() function,
an int and an array of character pointers.  The programmers of tftpd are
setting each of the pointers in their array to one of the arguments (if
there are any arguments).  By doing this, they reduce the risk of a
buffer overflow by not copying their command line arguments into static
buffers.  They simply point their variables at the arguments already in
memory, rather than duplicate them.

3)  Syntactically, the while loop is valid.  Style is quite left up to
the programmer.  If you feel like writing code that looks like Perl, you
can  :)
(I usually code fairly close to the GNU style guides)

MSG


Sam Bayne wrote:
 
 So There I am, rooting around in the source to the tftpd server
 (never you mind why) when I see this:
 
 -
 #define MAXARG  4
 static char *dirs[MAXARG+1];
 
 int
 main(int ac, char **av)
 {
 register struct tftphdr *tp;
 register int n = 0;
 int on = 1;
 
 ac--; av++;
 if (ac==0) dirs[0] = "/tftpboot";  /* default directory */
 while (ac--  0  n  MAXARG)
 dirs[n++] = *av++;
 -
 
 There are several things about this code that puzzle me.
 
 1.  It looks to me like 'dirs' is set to be a 5 character
 string by the MAXARG define, then they turn around
 and set a default of 9 characters? Didn't they just
 run right off the end of the array?
 
 2. Or am I misreading this and it's creating a list of up to
 5 acceptable directories? If that's so, where does it set
 the maximum size for each argument? If that's in some
 previous part of the declarations, that's fine, just
 give me an example construction to look for.
 
 3. Stylistically, is that 'while' statement normal? It looks to
 me like a syntax mistake waiting to happen, but I'll code
 to that style if it's normal for C programmers. Coming
 from a mostly perl background that line would either be
 one line or enclosed in curly braces.
 
 --
 -
 Sam Bayne - System Administrator
 North Seattle Community College
 [EMAIL PROTECTED] (206)527-3762
 =
 
 --
 To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
 as the Subject.


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-04 Thread Steve Borho

On Thu, May 04, 2000 at 05:23:37PM -0700, Sam Bayne wrote:
 while (ac--  0  n  MAXARG)
 dirs[n++] = *av++; 
 
 3. Stylistically, is that 'while' statement normal? It looks to
   me like a syntax mistake waiting to happen, but I'll code
   to that style if it's normal for C programmers. Coming
   from a mostly perl background that line would either be
   one line or enclosed in curly braces.

Speaking to just pure style, though, that while loop reminds me of the
most efficient C snippet I've ever seen.  It's the standard implementation
of strcpy.

for (;*s;)
  *d++ = *s++;

That while loop does the exact same thing, only it's copying an array of
character pointers instead of characters (with a bounds check for good
measure).

-- 
Steve Borho   Voice:  314-615-6349
Network Engineer
Celox Networking Inc

Fortune of the day:
I use not only all the brains I have, but all those I can borrow as well.
-- Woodrow Wilson


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-04 Thread Tim Hockin

 #define MAXARG  4
 static char *dirs[MAXARG+1];

a 5 element array of pointers to characters (strings).

 ac--; av++;
 if (ac==0) dirs[0] = "/tftpboot";  /* default directory */
 while (ac--  0  n  MAXARG)
 dirs[n++] = *av++; 

 1.  It looks to me like 'dirs' is set to be a 5 character
   string by the MAXARG define, then they turn around
   and set a default of 9 characters? Didn't they just
   run right off the end of the array?

nope - it's an array of strings (pointers to strings, actually)

   the maximum size for each argument? If that's in some

they don't.  It's a char * - it can point to as much memory as they can
malloc.

 3. Stylistically, is that 'while' statement normal? It looks to
   me like a syntax mistake waiting to happen, but I'll code
   to that style if it's normal for C programmers. Coming
   from a mostly perl background that line would either be
   one line or enclosed in curly braces.

there is no 'normal'.  If that makes sense to the programmer, then fine.
It is not particularly obfuscated...  code to however makes sense to you.
Just don't make it look like perl. ;)


Tim


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.




Re: C programming question...[OT]

2000-05-04 Thread Sam Bayne

First of all, thank everyone for helping me out with idiotic basic
questions.

Gordon Messmer wrote:
 
 1)  No, the programmers declared an array of 5 character pointers, not
 an array of 5 characters.  Perl 5 doesn't have pointers, so I understand
 your confusion  :) They're one of the things that non-C programmers
 bitch about.  (If you don't understand pointers, using them is a quick
 way to a segfault).

Hee hee, perl doesn't have pointers, but it DOES have references. (But
they have some idiot protections WRT segfault.) The thing that is really
confusing about C's pointers is not the "they're memory locations"
thing,
it's the way they get shuffled back and forth with pointer or array
notation at the programmer's whim. 
 
 2)  Yes, it's a list of up to five acceptable directories (or so it
 appears).  The maximum size of each of these is not defined, but will be
 the maximum size of a command line argument.  A pointer is an address in
 memory.  Every program is passed two arguments to its main() function,
 an int and an array of character pointers.  The programmers of tftpd are
 setting each of the pointers in their array to one of the arguments (if
 there are any arguments).  By doing this, they reduce the risk of a
 buffer overflow by not copying their command line arguments into static
 buffers.  They simply point their variables at the arguments already in
 memory, rather than duplicate them.

Ok, that was the actual question I was dancing around, so the
commandline
parser( I assume one of exec()'s brethren, whatever inetd is using) is
responsible for bounds checking these then?

 
 3)  Syntactically, the while loop is valid.  Style is quite left up to
 the programmer.  If you feel like writing code that looks like Perl, you
 can  :)
 (I usually code fairly close to the GNU style guides)

I'm going to look those up right quick.

-- 
-
Sam Bayne - System Administrator
North Seattle Community College
[EMAIL PROTECTED] (206)527-3762
=


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.