Re: [Lug-Nuts] C problems

From: Linux Rocks (gnulinux@rosecomputing.com)
Date: Sun Oct 24 1999 - 18:51:25 PDT


On Thu, Oct 21, 1999 at 11:17:15PM -0700, Brian Lavender wrote:
> Ok, I got it working thanks to Sean and Mike. Just a question. The man

> char salt[2];
>
> strcpy(salt,"abcde");

It may be working, but the above code looks wrong to me.

You declared a variable named 'salt' of type char that is two bytes in
size. Then you try to stuff 5 bytes of data ("abcde") or more likely 6
bytes of data ("abde" & \0) into the variable using strcpy. It may work,
but some compilers may let you accidentally overwrite memory this way,
giving you undefined funky results.



This archive was generated by hypermail 2b29 : Fri Feb 11 2000 - 16:20:20 PST