Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Header file



Comment



" ; " after loop



Working with switch case



Specifer




String_ CMP - strchr function




// AHF C PROGRAM SOLVING

//solving here CHARACTER MANIPULATION FUNCTION ( CMP ) 	programming problem

#include<stdio.h> #include<string.h> #define pf printf int main() { char str[50],ch; char *pos; //input data pf("Enter the string: "); gets(str); //input searching character pf("\nEnter the searching letter: "); scanf("%c",&ch); //find character and position pos=strchr(str,ch); //output will come first matching letter if(pos) pf("\n%c is found in the string at the position %d",ch,pos-str+1); else pf("\n%c is out of the string.",ch); return 0; }
OUTPUT:


© 2018 - All rights reserved