Hello friends!!!!!
To print the starting position of the character in the string
C LANGUAGE
11/21/20241 min read
// To print the starting position of the character in the string
#include <stdio.h>
#include<string.h>
int main() {
char a[50] = "Rishendra";
char *ch = strchr(a, 'e');
if(ch != NULL){
printf("The character R is at position : %ld", ch - a);
}
else{
printf("The given character is not found!!");
}
}
Output:
The character R is at position : 4
=== Code Execution Successful ===