I have been given a task at school to write a program that
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.
#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;
}
You can use the strcmp() function
to compare the strings.
Also, don't forget to clean up the memory pointed to by word3
using the free()
function before you are finished.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With