the strchr function

This is a discussion on the strchr function within the C Programming forums, part of the General Programming Boards category; hi, i wrote the strchr function in a full program but there is something wrong when calling the function and ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    90

    the strchr function

    hi, i wrote the strchr function in a full program but there is something wrong when calling the function and it gives me an expected error , here is the code :
    Code:
    #include <string.h>
    #include <stdio.h>
    #include <conio.h>
     void strchr(*s, char c)
     {
         while (*s != '\0' && *s != (char)c)
             s++;
         return ( (*s == c) ? (char *) s : NULL );
     }
     main()
     {
     char s[5],c;
     scanf("%s",&s);
     strchr(&s,c);
     printf("%s",s);
     getch();
     }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 03:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

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