The code is the following. It compiles without warnings or errors yet nothing is printed out on the terminal. Any ideas why?
I think the answer must be obvious yet, I cant see it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* palindrome (char *word);
main()
{
char *leksi, *inverse_leksi;
//leksi means word
leksi = malloc(sizeof(char)*256);
inverse_leksi = malloc(sizeof(char)*256);
gets(leksi);
inverse_leksi = palindrome(leksi);
puts(inverse_leksi);
}
char* palindrome (char *word)
{
int i;
char *inverse_word;
inverse_word = malloc(sizeof(char)*256);
for (i = 0; i < strlen(word) + 1; i++)
{
inverse_word[i] = word[strlen(word) - i];
}
return inverse_word;
}