Hi
I'm new in this forum. I'm an italian student (not an expert of c++) , so I perharps will not understand very well English (escuse me);
I wanted to create a program in C++ that let me to receive the translation in Morse Code of a string...
Do I do well operating with vectors, or I need something else?
I'm posting the text of the code.
I use Win XP and DEVc++ as compilator... it runs but not as i wonder!
If someone should answer me, I will be grate! :)
#include <iostream>
#include <windows.h> // WinApi header
#include <stdlib.h>
using namespace std;
int main()
{
int N,i;
N=5;
char v[N],type;
cout<<"INSERIRE MASSIMO 5 CARATTERI"<<endl;
for (i=0;i<N;i++)
cin>>v[i];
for (i=0;i<N;i++)
{
v[i]=type;
switch (type)
{
case 'a':
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'b':
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'c':
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'd':
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'e':
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'f':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'g':
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'h':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'i':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'l':
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'm':
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'n':
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'o':
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'p':
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 'q':
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'r':
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 's':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
case 't':
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'u':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'v':
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,250);
_sleep(100);
cin.get();
break;
case 'z':
Beep(900,250);
_sleep(100);
Beep(900,250);
_sleep(100);
Beep(900,100);
_sleep(100);
Beep(900,100);
_sleep(100);
cin.get();
break;
}}
return 0;
}