I am getting this error when trying to compile the below code.
"non-void function does not return a value in all control paths"
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
string cipher(string word);
int main(void)
{
string word1 = get_string("Enter word you want to be encoded.");
string codedMessage = cipher(word1);
printf ("Encoded message is: %s", codedMessage);
}
string cipher(string word)
{
string finish = ("");
for(int i = 0 , n = strlen(word); i < n; i++)
{
finish = finish + ((char)(word[i]+1));
return finish;
}
}
From what I can gather online, this means that I am not returning a value from my function?
All I want the function to do is add one to the value of the each character inputted into the string array and shift it on the ASCII table and then return the coded message. Is the code I've written here adequate to do that?