techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

.Net Interview Questions
C++ Interview Questions
Unix Interview Questions
                              .........More

Download e-Books
C Interview Questions e-book

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
                              .........More

Online Quiz
C Online Quiz
C++ Online Quiz
                              .........More

 

 

  

  Home > C Interview Questions >

Does there exist any other function which can be used to convert an integer or a float to a string ?

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\n”, i, f );

 

Have a Question ? post your questions here. It will be answered as soon as possible.