Thread: Proofing existing functions

  1. #16
    Ah, I see...

    Thanks for pointing that out, and I like the malloc() call using strlen(). Of course the "+ 1" for the NULL Terminator , but besides that, the const char * was a good call and then returning the pointer to another char*.

    Very nicely done Prelude!


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  2. #17
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    If you are proving existing functions I would change the toupper to your own version
    Code:
    int toupper(char *str){
         char *ptr=str;
         while(*str){
              *ptr=(*ptr)-'32';
         }
         return str;
    }
    It also does error checking though; I am too lazy for that right now(You would have to write your own isalpha() func).

  3. #18
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Quote Originally Posted by Prelude
    Without me you would be in the depths of segfault hell, forced to port VAX/VMS applications to MS-DOS while being whipped with hardcopy of the Windows 3.0 source code by Herbert Schildt.
    Someone's fantasy perhaps? I laughed pretty hard at this one ^ ...good times.

    ~/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  2. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  3. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM
  4. Inline functions and inheritance
    By hpy_gilmore8 in forum C++ Programming
    Replies: 3
    Last Post: 01-14-2004, 06:46 PM
  5. functions - please help!!!!
    By linkies in forum C Programming
    Replies: 1
    Last Post: 08-21-2002, 07:53 AM