Skip to content

Instantly share code, notes, and snippets.

@bebyx
Created January 16, 2021 11:36
Show Gist options
  • Save bebyx/dd8726484a58aa5bc7959f779f63397c to your computer and use it in GitHub Desktop.
Save bebyx/dd8726484a58aa5bc7959f779f63397c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
char* latinize(char *word);
int main() {
char sentence[100];
char *token, *word;
const char delimiter[2] = " ";
fgets(sentence, 100, stdin);
sentence[strcspn(sentence, "\n")] = 0;
token = strtok(sentence, delimiter);
while( token != NULL ) {
word = token;
printf("%s ", latinize(word));
token = strtok(NULL, delimiter);
}
puts("");
return 0;
}
char* latinize(char *word) {
static char latinized_word[50];
char buffer[50];
strcpy(buffer, &word[1]);
strncat(buffer, word, 1);
strcat(buffer, "ay");
strcpy(latinized_word, buffer);
return latinized_word;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment