// Justin C. Miller
// University of Wisconsin Oshkosh
// made for: http://www.geocities.com/neonprimetime.geo/index.html
// done in: Borland Builder 4.0
// Date: 3-2-2001
// Title: using atof and atol
// atof converts a string to a floating point number
// atol converts a string to a long int
#include
#include
void Function(int nbr);
int main()
{
char floating_number[5] = "75.3" ;
char long_number[8] = "5312312" ;
float a = atof(floating_number) ;
long b = atol(long_number) ;
cout << "char floating_number[5]=" << floating_number << endl ;
cout << "atof(floating_number)=" << a << endl ;
cout << "char long_number[5]=" << long_number << endl ;
cout << "atof(long_number)=" << b << endl ;
return 0 ;
}
void Function(int nbr)
{
char FileName[5] = "file" ;
char number[5] ;
// itoa converts integers to strings
// itoa takes 3 parameters
// 1st is the integer to convert
// 2nd is the string to store it it
// 3rd is the base (most times it's 10 which is decimal)
itoa(nbr, number, 10) ;
char Extension[5] = ".txt" ;
strcat(FileName, number) ;
strcat(FileName,Extension) ;
cout << FileName << endl ;
}
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)