Skip to content

Instantly share code, notes, and snippets.

@Technicus
Created April 20, 2014 07:36
Show Gist options
  • Save Technicus/11107686 to your computer and use it in GitHub Desktop.
Save Technicus/11107686 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <conio.h>
int sOcc(char *ptr, char specialChar);
main(){
char myArray[80], search, *ptr;
int cnt=0;
printf(" Please enter a phrase... ");
gets(myArray);
printf(" Please enter a search char ...");
scanf(" %c", &search);
printf(" I found %d search characters",sOcc(myArray,search));
while(!kbhit()){}
}
int sOcc(char *ptr, char specialChar){
int cnt=0;
while( *ptr != '\0'){
if( *ptr == specialChar){
cnt++;
}
ptr++;
}
return(cnt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment