I am writing a few programs in C. I am stuck. i am not sure how to use strcmp or strncmp. i cant find any websites that can help and my book does not give any good examples. This is what i have to do.
Frist..... Write a program that inputs a line of text with function gets into char array s[100]. Output the line in uppercase letters and in lowercase letters.
Second....Write a program that uses function strcmp to compare two strings input by the user. The program should state whether the first string is less than, equal to or greater than the second string.
Third..... Write a program that uses function strncmp to compare two strings input by the user. The program should input the number of characters to be compared. The program should state whether the first string is less than, equal to or greater than the second string.
These 3 programs should be combined into 1 program.
I am stuck and here is what i have so far. I have completed the first program but i am having trouble with the second and third program. Can you help me with? or maybe steer me in the right direction ? Thanks I appreciate it.
Code:#include <stdio.h> #include <ctype.h> # define SIZE 80 int main() { int i; char s[SIZE]; /* prompt user to enter line of text */ puts( "Enter line of text:\n" ); gets(s); /* use gets to display sentence */ printf("Upper case lines:\n"); for (i=0; i < strlen(s); i++) printf("%c", toupper(s[r])); printf("\n"); printf("Lower case line:\n"); for(i=0; i < strlen(s); i++) printf("%c", tolower(s[r])): print("\n"); char s1{80}; char s2{80}; int x;