I am writing a program that will convert Morse code to alphabet and vice versa.
Here is the code so far
This is just a test program and I haven't finished yet. But I get an error when I run the program. It gets to where you can select among the three options. When I select a number and hit enter I getCode:#include <stdio.h>
int main()
{
char *alpha[26] =
{
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
};
char *morse[26] =
{
".-",
"-...",
"-.-.",
"-..",
".",
"..-.",
"--.",
"....",
"..",
".---",
".-.-",
".-..",
"--",
"-.",
"---",
".--.",
"--.-",
".-.",
"...",
"-",
"..-",
"...-",
".--",
"-..-",
"-.--",
"--..",
};
int w;
while( w != 3)
{
w=0;
printf("Please select an option\n");
printf("1. Encode\n");
printf("2. Decode\n");
printf("3. Quit\n");
scanf("%d", w);
if(w==1)
printf("Encode\n"); //Encode function goes here
else if(w==2)
printf("Decode\n"); //Decode function goes here
else
printf("Wrong option selected\n");
}
}
"(Name of File) has generated errors and will be closed by Windows. You will need to restart the program.
An error log is being created."
Does anyone know or see what I am doing wrong? Thanks for the help in advance.