watshamacalit230
Programmer
my compiler keeps giving me this error...
C:\Program Files\Microsoft Visual Studio\MyProjects\11\1101x01kt.cpp(25) : error C2664: 'english_number' : cannot convert parameter 1 from 'char [81]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
what does that mean?
this program is supposed to write the numbers in english( the way we really say them )...from 0-100...i've done it all but i keep getting this error so i've only posted the first half of my code cuz its so long...
heres my code...
C:\Program Files\Microsoft Visual Studio\MyProjects\11\1101x01kt.cpp(25) : error C2664: 'english_number' : cannot convert parameter 1 from 'char [81]' to 'char'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
what does that mean?
this program is supposed to write the numbers in english( the way we really say them )...from 0-100...i've done it all but i keep getting this error so i've only posted the first half of my code cuz its so long...
heres my code...
Code:
#include <stdio.h>
char* english_number( char string ) ;
void get_string( char buffer[], int size ) ;
const int LENGTH = 81 ;
void main( void )
{
char line[ LENGTH ] ;
int count ;
printf( "Enter a number : " ) ;
get_string( line, LENGTH ) ;
printf( "English : " ) ;
for( count = 0 ; line[count] != '\0' ; count++ )
/*error here -->*/ printf( "%s ", english_number( line ) ) ;
}
char* english_number( char string )
{
if ( string >= '0' && string <= '10' )
{
if ( string == '0' )
return ( "zero" ) ;
else if ( string == '1' )
return( "one" ) ;
else if ( string == '2' )
return( "two" ) ;
else if ( string == '3' )
return( "three" ) ;
else if ( string == '4' )
return( "four" ) ;
else if ( string == '5' )
return( "five" ) ;
else if ( string == '6' )
return( "six" ) ;
else if ( string == '7' )
return( "seven" ) ;
else if ( string == '8' )
return( "eight" ) ;
else if ( string == '9' )
return( "nine" ) ;
else if ( string == '10' )
return( "ten" ) ;
}
}
void get_string( char buffer[], int size )
{
char character;
int j = 0;
do /* Get a character until newline or */
{ /* we run out of characters. */
character = getchar() ;
buffer[j] = character ;
++j;
}
while ( character != '\n' && j < size ) ;
while ( character != '\n' ) /* Get rid of extra characters. */
character = getchar() ;
buffer[j - 1] = '\0' ; /* Replace newline with the null-byte. */
}