Re: Linux programme - different results each run
- From: Paul Pluzhnikov <ppluzhnikov-nsp@xxxxxxxxxxx>
- Date: Sun, 11 Dec 2005 09:13:32 -0800
Eric Enright <eric.enright@xxxxxxxxx> writes:
>> int isNum(char data)
>> {
>>
>> switch(data)
>> {
>> case '0': return 0;
>> case '1': return 0;
....
> There is a function called isdigit() in ctype.h that
> does just this, you should use it instead.
In addition, isSomething() should return non-zero when something
is true, and zero (false) otherwise.
As written, the code will require anyone with any "C" experience
to go through extra "this code works backwards" mental gymnastics.
>> char *path = (char *)malloc(50);
>
> What happens if malloc() fails? Plus, you shouldn't
> be casting malloc().
>
>> strcat(path,"/proc/");
One more bug: what happens if storage returned by malloc() did
not begin with a NUL byte?
I believe that bug is at the root of OPs irreproducible results.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.
- References:
- Linux programme - different results each run
- From: ulyses
- Re: Linux programme - different results each run
- From: Eric Enright
- Linux programme - different results each run
- Prev by Date: Re: Escaping backslash [programming question]
- Next by Date: Problem with linking
- Previous by thread: Re: Linux programme - different results each run
- Next by thread: Re: Linux programme - different results each run
- Index(es):
Relevant Pages
|