Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
string[] lines = File.ReadAllLines("test_words.txt"); // This reads the input coded message from test words
string decodedMessage = "";
foreach (string word in lines) // Loops throught the test words file
{
if (word == "SPACE")
{
decodedMessage += ' '; // Puts a space in the proper position in output
}
else if (word == "COMMA")
{
decodedMessage += ','; // Puts a comma in the proper position in output
}
else
{
if (word.Length > 0) // This is to make sure the word isnt empty
{
decodedMessage += word[0];
}
else
{
decodedMessage += ""; // Replace '\0' with an empty string
}
}
}
Console.WriteLine(decodedMessage); // Prints out the output in the terminal
File.WriteAllText("decoded.txt", decodedMessage); // Writes the decoded message output to the decoded file