Hi,
I have been given a task at school to write a program that
- Reads three strings
- Stores the third string in dynamically allocated memory
- Print out the last 4 letters of the first word alphabetically.
Here is the program I have so far. The strings are all stored in different variables, making them hard to sort. If anyone could give me a hand and help me finish this program, I would be very grateful.
Thanks
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char word1[101];
char word2[101];
char* word3;
char buffer[101];
scanf("%s", word1);
scanf("%s", word2);
scanf("%s", buffer);
word3 = (char *) malloc(strlen(buffer)+1);
strcpy(word3, buffer);
return 0;
}