printf("\n\tEnter in a phrase in English for encrypting\n");
("%s", phr);
len=strlen(phr);
printf("The phrase that u enter is: \n");
for(i=0; i<len; i++)
{
printf("%c", phr[i]);
}
printf("\nConverting the phrase to Morse Code.... \n");
for(a=0; a<len; a++)
{
for(b=0; b<37; b++)
{
if(tolower(phr[a])==alpha[b])
printf("%s ", morse[b]);
}
}
printf("\n\tDone!\n");
i need to encode phrases , between phrase, there's 3 spaces.
The phrase that you enter is :
:)
Converting the morse code...
Done!
Actually I said fgets, since gets is deprecated, but this is not the problem. The following code works:
1 2 3 4 5 6 7 8 9 10 11 12 13
#include<stdio.h>
int main() {
char word[100];
printf("\n\tEnter in a phrase in English for encrypting: ");
fgets(word, 99, stdin);
printf("The phrase that u enter is: %s\n", word);
return 0;
}
Not at all! (word) is the name of the variable, and in this case it is an array of char. Its size is the number specified between the square brackets: this means that (word) can contain up to 100 characters. Note that this doesn't mean that it contains exactly 100 chars: it is just a maximum potential size.
You should post the entire code, so that we can take a look and correct the mistakes. It's easier for us to work on a complete code, that we can compile and run on our own.