This is an unfinished code for converting alphanumeric characters into Morse code. So far only the character "A" is in set. I can't seem to copy the Morse code string of "a" into the variable "c". The compiler tells me that passing argument 1 of strcpy
makes pointer from integer without a cast.
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(){
char c; /* variable to hold character input by user */
char sentence[ 80 ]; /* create char array */
int i = 0; /* initialize counter i */
const char *a = ".- ";
/* prompt user to enter line of text */
puts( "Enter a line of text:" );
/* use getchar to read each character */
while ( ( c = getchar() ) != '\n') {
c = toupper(c);
switch (c){
case 'A':
strcpy(c, a);
break
}
sentence[ i++ ] = c;
} /* end while */
sentence[ i ] = '\0'; /* terminate string */
/* use puts to display sentence */
puts( "\nThe line entered was:" );
puts( sentence );
return 0;
}