Re: Please help optimize (and standarize) this code...
From: gtippery (gtippery_at_altavista.net)
Date: 03/12/05
- Next message: Emmanuel Delahaye: "Re: fgets, EOF in middle of line, does not cause error"
- Previous message: Emmanuel Delahaye: "Re: Correct function prototype format for ANSI C"
- In reply to: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Next in thread: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Reply: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 12 Mar 2005 02:30:13 -0800
Mark F. Haigh wrote:
> gtippery wrote:
> > Mark F. Haigh wrote:
> >
>
> <large snip>
>
> > If you just wanted to show something similar, that's fine, and it
was
> > interesting. But the reason I didn't use an array of strings in
the
> > first place is that in the real program, the data's coming from an
> > existing packed data structure in memory (returned by the OS), and
> > would have to be converted to strings to use your sentinel and
> printing
> > techniques; so as far as I can see I'd need the memcpy()'s anyway.
>
> And how was I supposed to know this? State this up front next time.
The "real app" is mentioned in the original post (in a comment).
Anyway, I wasn't objecting, just explaining.
> I'd thought it was for some kind of class project (first name / 3
digit
> telephone extension), and that you had poor taste in data structures
> and compilers.
Well, "de gustibus non est disputandum", and I've no reason to think
mine's particularly good. The compiler choice is partially dictated by
the target system, which runs PC-DOS 6. I've also got Borland's
compiler, but it seemed like overkill. PowerC, as far as I've seen to
date, has all the C89 features except localization (if that's strictly
C89). It may not be "picky" enough -- I need to check the options in
the docs.
>
...
> I'll take another look when I get some time. Disregard the previous
> post, and note:
>
> 1. Yes, you should cast size_t to int if it's going to be going
> through the default argument promotions.
I learned this from an earlier post in this same thread, myself.
> 2. There are all kinds of dirty tricks and pre-canned "divide by x"
> code sequences for compiler writers. Look at "Hacker's Delight" by
> Henry S. Warren Jr. for more info on some interesting tricks (magic
> numbers, etc).
>
Noted.
> 3. What's the biggest number of elements that your array can have?
> Check your platform docs. It may be more than int can handle, but
less
> than or equal to what size_t can handle.
>
The platform limit is 64KB for any one item (i8086). The array would
be the limiting factor in this case (at something over 5,000 elements),
but it's never going to get that big - the maximum dimension is 512.
If size_t isn't actually an int (of some standard type), isn't that
going to be a problem in the for()? I thought the index variable had
to be an integer or enumeration.
> 4. Always put a return statement in main. It's necessary in C89,
and
> good style in C99.
...
Thanks.
- Next message: Emmanuel Delahaye: "Re: fgets, EOF in middle of line, does not cause error"
- Previous message: Emmanuel Delahaye: "Re: Correct function prototype format for ANSI C"
- In reply to: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Next in thread: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Reply: Mark F. Haigh: "Re: Please help optimize (and standarize) this code..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|