Re: strlen



Gordon Burditt wrote:

I can't imagine myself writing a program that would
check the return value of a function
to see if invalid arguments had been passed,
instead of writing the program
to ensure that the arguments were valid,
prior to making the function call.

Ok, try this one. How would you verify this call before making it?

#include <stdio.h>
...
FILE *f;

f = fopen("C:\\log.txt", "w");

I would be checking the return value
to see if the operation succeded,
regardless of what the cause
of any potential failure might happen to be.

--
pete
.



Relevant Pages

  • Re: strlen
    ... gordonb.902u1@xxxxxxxxxxx (Gordon Burditt) writes: ... to see if invalid arguments had been passed, ... instead of writing the program ... A null pointer, on the other hand, is not a valid argument to ...
    (comp.lang.c)
  • Re: Where to put the error handing test?
    ... since you're writing it all. ... This is clearly a redundancy to the code. ... you'll be a long time finding all the bugs in non-trivial code. ... and write careful documentation describing what's invalid. ...
    (comp.lang.python)
  • Re: Where to put the error handing test?
    ... Or you could be referring to a test that notices bad input by a user, or bad data from an untrusted source. ... And there are variations of these, depending on whether your user is also writing code, etc. ... If you throw the code together without a test suite, you'll be a long time finding all the bugs in non-trivial code. ... If you're writing a library to be used by others, then define your public interfaces with exceptions for any invalid code, and write careful documentation describing what's invalid. ...
    (comp.lang.python)
  • Re: rd.d/power_profile: dev.cpu.0.cz_supported doesnt exist
    ... sysctl: hw.acpi.cpu.cx_lowest: Invalid argument ... what mobo? ... It works on my 64-bit system I'm writing this ...
    (freebsd-stable)
  • Re: From The Guardian - Radio show had it all - except sound
    ... This reminds me of my boyhood habit of writing to such organisations as Radio Moscow. ... Please replace invalid and invalid with gmx and net to reply. ...
    (uk.tech.broadcast)

Loading