C string program
Posted
by mrblippy
on Stack Overflow
See other posts from Stack Overflow
or by mrblippy
Published on 2010-06-07T04:20:13Z
Indexed on
2010/06/07
4:22 UTC
Read the original article
Hit count: 193
c
Hi, i have been given a task to do ar school that must read three strings in, store the third string in dynamically allocated memory and print out the last 4 letters of the first word alphabetically. Here is the program i have so far but 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;
}
© Stack Overflow or respective owner