/* EDCXBS35
    This example finds the first occurrence of the character p in
    "computer program".
  */
#include <stdio.h>
#include <string.h>

#define SIZE 40

int main(void)
{
    printf("practice1: strch\n");
  char buffer1[SIZE] = "computer program";
  char * ptr;
  int    ch = 'p';
    ptr = strchr (buffer1, ch);

    printf("read from \'%c\' in \"%s\": %s\n", ch, buffer1, ptr);

    char name[SIZE] = "kim taejong";
    char * p_char = NULL;
    char char1 = 'j';
    p_char = strchr(name, char1);

    printf("original name: \"%s\"\n", name);
    printf("read from \'%c\': \"%s\"\n", char1, p_char);

    printf("practice2: strstr\n");
    char * p_str = NULL;
    char str[] = "ae";
    p_str = strstr(name, str);
    printf("read from \'%s\' : \"%s\"\n", str, p_str);



}


Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: