hi im writing a program to decode a morse code message. my program compiles without any error but nothing happens when i enter my code to be decoded. i think there might be something wrong in the "int main()" part of my program. i could really use some help.
You really need to format your code to be more readable. You will have to change your login in main(). I put the string of morse code into a file and ran your program like this:
1 2 3
cat input | main
What happens is that all of the contents of the input is assigned to temp -- not each morse character. You will want to think about parsing the result of cin >> temp, then pushing back.
I'm not sure what you mean ? So I have to put the morse code I want to be decoded in a file then run my program. Then pass the code before pushing back onto vector.
What is cat input l main? Does this go in "int main()"?
is a way to run your program on UNIX, Linux, and even Windows. The "cat" command opens the file named "input" and writes its contents on the standard output device (usually your monitor). The word "main" is the name of your program -- I simply chose that name.
You don't have to put your code into a file: It's just a very quick way to test, over and over.
What I was trying to say is that when you use:
1 2 3
cin >> temp;
All of the characters that you type get stored into temp, but temp doesn't know when you are finished with the string. At the end of the string you can type ctrl-d (which means end-of-file) and the program will work.