CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include<cstring>
using namespace std;
//In C++, strchr() is a predefined function used for finding occurrence of a character in a string.
//To find a character in a position.Suupose the character a is in 9th position of the string 'This is a string'.so It will return 9.
char* strchr(const char* s, int c)
{
for(const char* p=s; p && *p; p++)
{
if(*p == c)
{
return (char*)p; //returning the character
}
}
return 0; //else
}
int main()
{
char string[80];
cout<<"Enter a sentence: ";
cin.getline(string,80);
char m;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run