C Programming - Library Functions - Discussion
Discussion Forum : Library Functions - General Questions (Q.No. 3)
3.
Which standard library function will you use to find the last occurance of a character in a string in C?
Answer: Option
Explanation:
strrchr() returns a pointer to the last occurrence of character in a string.
Example:
#include <stdio.h>
#include <string.h>
int main()
{
char str[30] = "12345678910111213";
printf("The last position of '2' is %d.\n",
strrchr(str, '2') - str);
return 0;
}
Output: The last position of '2' is 14.
Discussion:
18 comments Page 2 of 2.
Rajes said:
9 years ago
Thanks @Srikanth.
ISHWARYA said:
8 years ago
Thank you so much @Srikanth.
Mostafa Yasin said:
8 years ago
Thanks @Ashish.
Prateek said:
8 years ago
Thanks @Srikanth.
Suraj said:
8 years ago
Nice explanation @Srikanth.
Sridhar said:
7 years ago
Why the array range from 50 to 66 @Srikanth.
(1)
Suchi said:
7 years ago
I am not getting can anyone explain option D.
(1)
Mayur22kar said:
4 years ago
Thanks @Srikanth.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers