Skip to content

Instantly share code, notes, and snippets.

@Technicus
Created February 26, 2014 01:37
Show Gist options
  • Save Technicus/9221705 to your computer and use it in GitHub Desktop.
Save Technicus/9221705 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void main(){
char theArray[80], searchChar;
int index=0, count=0;
printf("\n Enter the phrase.\n\n");
gets(theArray);
printf("\n What character do you want to find: ");
scanf(" %c", &searchChar);
printf("\n You are looking for: %c \n", searchChar);
//scanf(" %s", &theArray[0]);
while( theArray[index] != '\0'){
if (theArray[index] == searchChar){
count++;
}
index++;
}
printf(" Length = %d\n", index);
printf(" count = %d\n", count);
printf("\n ECHO: %s\n\n", theArray);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment