|
INTERVIEW QUESTIONS
C
FUNCTIONS IN C
DETAILS
Question: Does there exist any other function which can be used to convert an integer or a float to a string ?
Answer: Some implementations provide a nonstandard function called itoa(), which converts an integer to string.
#include
char *itoa(int value, char *string, int radix);
DESCRIPTION The itoa() function constructs a string representation of an integer.
PARAMETERS value: Is the integer to be converted to string representation.
string: Points to the buffer that is to hold resulting string. The resulting string may be as long as seventeen bytes.
radix: Is the base of the number; must be in the range 2 - 36.
A portable solution exists. One can use sprintf():
char s[SOME_CONST]; int i = 10; float f = 10.20;
sprintf ( s, “%d %f ”, i, f );
|
|
|
Category |
Functions in C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8923 users |
Added on |
9/18/2014 |
Views |
71899 |
Rate it! |
|
|
Question:
Does there exist any other function which can be used to convert an integer or a float to a string ?
Answer:
Some implementations provide a nonstandard function called itoa(), which converts an integer to string.
#include
char *itoa(int value, char *string, int radix);
DESCRIPTION The itoa() function constructs a string representation of an integer.
PARAMETERS value: Is the integer to be converted to string representation.
string: Points to the buffer that is to hold resulting string. The resulting string may be as long as seventeen bytes.
radix: Is the base of the number; must be in the range 2 - 36.
A portable solution exists. One can use sprintf():
char s[SOME_CONST]; int i = 10; float f = 10.20;
sprintf ( s, “%d %f ”, i, f ); Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
Advantages of a macro over a function ?
|
View Answer
|
|
What is the difference between printf() and sprintf() ?
|
View Answer
|
|
What is the code for clrscr() function?
|
View Answer
|
|
How to use the cprintf,cscanf,sscanf,sprintf,vsscanf,vsprintf,vscanf & vprintf?
|
View Answer
|
|
How to convert decimal to octal and hexadecimal in c program?
|
View Answer
|
|
How to use floodfill() function and what is the use of kbhit?
|
View Answer
|
|
Write a program with out using main() function?
|
View Answer
|
|
Can there be at lest some solution to determine the number of arguments passed to a variable argument list function?
|
View Answer
|
|
What do the functions atoi(),itoa()and gctv()do?
|
View Answer
|
|
How would you use bsearch()function to search a name stored in array of pointers to string?
|
View Answer
|
|
How would you use the functions sin(),pow(),sqrt()?
|
View Answer
|
|
how would you use the functions memcpy(),memset(),memmove()?
|
View Answer
|
|
How would you use the functions randomize()and random()?
|
View Answer
|
|
How would you use the functions randomize()and random()?
|
View Answer
|
|
what is the difference between the functions rand(),random(),srand() and randomize()?
|
View Answer
|
|
Can you use the function fprintf()to display the output on the screen?
|
View Answer
|
|
How to see return value of main function?
|
View Answer
|
|
How to write a program in c to print its own code?
|
View Answer
|
|
What is the function of c?
|
View Answer
|
|
1. what is a difference between printf and cout . and why printf called a function and cout object as both are used to print data?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Functions in C Interview Questions & Answers - Exam Mode /
Learning Mode
|