Re: How so ?
From: Kelsey Bjarnason (kelseyb_at_lightspeed.bc.ca)
Date: 02/10/04
- Next message: Jeff Relf: "Re: . The whitespace ."
- Previous message: Marco de Boer: "SYSLINK : LIS_VISITED"
- In reply to: Tim Robinson: "Re: How so ?"
- Next in thread: Tim Robinson: "Re: How so ?"
- Reply: Tim Robinson: "Re: How so ?"
- Reply: The Ghost In The Machine: "Re: How so ?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 09 Feb 2004 19:13:28 -0800
[snips]
On Sun, 08 Feb 2004 11:14:27 +0000, Tim Robinson wrote:
> Anyone can learn C coding on Windows given a copy of Kernighan & Ritchie and
> a copy of Petzold.
I rather think not. For one thing, "coding C" turns out to be a *little*
more complex than simply cranking code that'll compile. For example, I've
seen way too many programs using undefined, improper or simply silly
constructs. Here's some examples:
char *s = malloc( 100 * sizeof(char) );
double *d = (double *) malloc( 100 * sizeof( *d ) );
float *f = malloc( 100 * sizeof(float) );
void main()
int main() { /* code */ return 1; }
char *func()
{
char buff[128];
/* store something in buff */
return buff;
}
char *mystrdup( const char *s )
{
char *d = NULL;
if ( s )
{
d = malloc( strlen(s) );
if (d)
strcpy(d,s);
}
return d;
}
int x;
printf( "Please enter your number: " );
scanf( "%d", &x );
/* Determine number of bits in an int */
size_t bits = sizeof(int) / 8;
And on and on and on. All or at least most of these _look_ like they
should be good, but it requires a certain degree of experience to know why
each of them is either wrong, silly, or simply a bad idea. Simply reading
the books - even very attentively - is probably not going to suffice to
explain why they're bad, especially since the compiler probably won't say
thing one about most of 'em.
- Next message: Jeff Relf: "Re: . The whitespace ."
- Previous message: Marco de Boer: "SYSLINK : LIS_VISITED"
- In reply to: Tim Robinson: "Re: How so ?"
- Next in thread: Tim Robinson: "Re: How so ?"
- Reply: Tim Robinson: "Re: How so ?"
- Reply: The Ghost In The Machine: "Re: How so ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|