strrchr

This is a discussion on strrchr within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, Does anyone know why the old C function "strrchr" has been implemented in C++ as Code: const char ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248

    strrchr

    Hi everyone,

    Does anyone know why the old C function "strrchr" has been implemented in C++ as

    Code:
    const char * strrchr ( const char * str, int character );
          char * strrchr (       char * str, int character );
    and not as

    Code:
    char * strrchr ( const char *, int );
    Some old C libraries won't compile anylonger...

    Thanks!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,636
    strrchr returns a pointer to the character found (or a null pointer otherwise). As such, it makes sense that if you pass it a pointer to something that should not be changed, you get back a pointer to something that should not be changed.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 05-28-2009, 09:30 AM
  2. strrchr help
    By newcguy in forum C Programming
    Replies: 6
    Last Post: 06-05-2007, 04:25 PM
  3. Counting characters
    By Calavera in forum C Programming
    Replies: 5
    Last Post: 10-01-2004, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21