

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strchr() function in C/C++
The function strchr() is used to search the character in the string. It search the first occurrence of character which is passed as second argument and it returns a pointer to the character, if successful otherwise, NULL.
Here is the syntax of strchr() in C language,
char *strchr(const char *string , int character)
Here,
string − The string which is to be scanned to search the character.
character − The character which is to be searched in the string.
Here is an example of strchr() in C language,
Example
#include<stdio.h> #include<string.h> int main() { char s[] = "Helloworld!"; char c = 'o'; char *result = strchr(s, c); printf("String after searching the character : %s", result); return 0; }
Output
String after searching the character : oworld!
In the above program, a char type string is passed and a character which is to be searched in the string. The result is stored in pointer variable *result.
char s[] = "Helloworld!"; char c = 'o'; char *result = strchr(s, c);
- Related Questions & Answers
- strchr() Function in C++
- strchr() function in C++ and its applications
- strchr() function in PHP
- iswlower() function in C/C++
- towupper() function in C/C++
- iswdigit() function in C/C++
- strftime() function in C/C++
- iswblank() function in C/C++
- iswpunct() function in C/C++
- strtod() function in C/C++
- memmove() function in C/C++
- memcpy() function in C/C++
- atexit() function in C/C++
- raise() function in C/C++
- mbrlen() function in C/C++
Advertisements