Thread: the strchr function

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

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, 04:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03: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