Hey guys...

I want to write a program that transforms numbers into letters and letters into numbers...

for example 20 would be transformed into twenty

I have this but I don't know what's missing or what's the problem... help please

#include <iostream>
#include <string>

using namespace std;
using std::string;
void ones(string);

int main(){


int number;


cout<<"ENter:"<<endl;
cin>>number;

switch(number.length())
{
case 1: ones(number);


}

system("pause");
return 0;


}

void ones(int numero)
{
int x;
x=atoi (numero);

switch(x)
{
case 1: cout<<"one"<<endl;
case 2: cout<<"two"<<endl;
case 3: cout<<"three"<<endl;
case 4: cout<<"four"<<endl;
case 5: cout<<"five"<<endl;
case 6: cout<<"six"<<endl;
case 7: cout<<"seven"<<endl;
case 8: cout<<"eight"<<endl;
case 9: cout<<"nine"<<endl;
case 0: cout<<"zero"<<endl;

}

}

You have number declared as an integer, but you are treating it as a string. There is no "int" class, so you cannot use the dot operator as you do in line 17. Use an if statement instead of the switch statement on line 17:

if (number >= 0 && number < 10)
   ones(number);

And please dont use

system("pause");

it is not a good approach.. use getch etc instead :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.