Created
August 20, 2015 08:54
-
-
Save SwadhInz/4c281d9f8ca72ff03dac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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