/************************************************************************
*																		*
* ders 10 ornekleri - Deniz Demiray										*
* string uzunlugu bulup kopyalayan program								*
* derlemek icin gcc -o program_ismi 8.c									*
*																		*
************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char string[50], *ptr, character;
	
	printf("Enter a sentence:\n");
	
	gets(string);
	
	ptr=string;
	
	printf("Enter a character:\n");
	
    scanf("%c", &character);
	
	printf("\nThe sentence: %s\n", string);
	
	if (strchr(string,character)!=NULL) {
		
		printf("\n%c is included in the sentence\n", character);
		printf("The address of the first occurrence of %c is %x\n", character, strchr(string,character));
        printf("The first occurrence is in the %dth element\n", strchr(string,character)-ptr+1);
        printf("The address of the last occurrence of %c is %x\n", character, strrchr(string,character));
        printf("The last occurrence is in the %dth element\n", strrchr(string,character)-ptr+1);
    }
	else 
	   printf("\n%c is not included in the sentence\n", character);

	
	
	system("pause");
	
	return 0;
}
