Skip to content

Instantly share code, notes, and snippets.

@SwadhInz
Created August 20, 2015 08:54
Show Gist options
  • Save SwadhInz/4c281d9f8ca72ff03dac to your computer and use it in GitHub Desktop.
Save SwadhInz/4c281d9f8ca72ff03dac to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
char str[100], ch;
int i, k;
k = 0;
gets(str);
scanf("%c", &ch);
for(i = 0; str[i] != '\0'; i++) {
if(str[i] == ch) {
if(!k) {
printf("character found at position: %d", i+1);
k = 1;
}
else
printf(", %d", i+1);
}
}
if(!k)
printf("Not found.\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment