C Programming - Library Functions
Why should I learn to solve C Programming questions and answers section on "Library Functions"?
Learn and practise solving C Programming questions and answers section on "Library Functions" to enhance your skills so that you can clear interviews, competitive examinations, and various entrance tests (CAT, GATE, GRE, MAT, bank exams, railway exams, etc.) with full confidence.
Where can I get the C Programming questions and answers section on "Library Functions"?
IndiaBIX provides you with numerous C Programming questions and answers based on "Library Functions" along with fully solved examples and detailed explanations that will be easy to understand.
Where can I get the C Programming section on "Library Functions" MCQ-type interview questions and answers (objective type, multiple choice)?
Here you can find multiple-choice C Programming questions and answers based on "Library Functions" for your placement interviews and competitive exams. Objective-type and true-or-false-type questions are given too.
How do I download the C Programming questions and answers section on "Library Functions" in PDF format?
You can download the C Programming quiz questions and answers section on "Library Functions" as PDF files or eBooks.
How do I solve C Programming quiz problems based on "Library Functions"?
You can easily solve C Programming quiz problems based on "Library Functions" by practising the given exercises, including shortcuts and tricks.
Example: rewind(FilePointer);
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.
1. itoa() converts an integer to a string.
2. ltoa() converts a long to a string.
3. ultoa() converts an unsigned long to a string.
4. sprintf() sends formatted output to a string, so it can be used to convert any type of values to string type.
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int num1 = 12345;
float num2 = 5.12;
char str1[20];
char str2[20];
itoa(num1, str1, 10); /* 10 radix value */
printf("integer = %d string = %s \n", num1, str1);
sprintf(str2, "%f", num2);
printf("float = %f string = %s", num2, str2);
return 0;
}
// Output:
// integer = 12345 string = 12345
// float = 5.120000 string = 5.120000