Question: I need help my program does not work and I also do not know how to complete the problem. My values keep coming back incorrect.

I need help my program does not work and I also do not know how to complete the problem. My values keep coming back incorrect. For example if I enter batman for hero, and batman for villain it will still say "hero is bigger than villain." I also have no idea how to CONCATENATE them. Please help me out, I typed out the code I have written so far.

--------------------------------------------------------------------------------------------------------------------------------------------------------

I need help my program does not work and I also do

#define _CRT_SECURE_NO_WARNINGS

#include

#define SIZE 50

#include

int main(void){

//Variable Declaration:

char hero[SIZE] = " ";

char antiHero[SIZE] = " ";

int result;

//Hero:

printf(" Enter the name of your favorite Super Hero: ");

scanf("%s", &hero);

printf("Your hero is %s ", hero);

printf(" Hero length is %d ", strlen(hero));

//Villain:

printf(" Enter the name of your favorite Villain: ");

scanf("%s", &antiHero);

printf("Your villain is %s ", antiHero);

printf(" Villain length is %d ", strlen(antiHero));

// String Comparison

result = strncmp(hero, antiHero, SIZE);

/* If the villain string is bigger */

if (antiHero > hero)

{

printf(" Villain String is more than the Hero ");

}

/* If the Hero string is bigger */

else if (antiHero

{

printf(" Villain string is less than the Hero ");

}

else if(hero == antiHero)

{

printf("Both the Hero and the Villain contain the same string number. ");

}

result = (hero - antiHero);

printf("the value of number is %d", result);

return 0;

}

STRING PROBLEM: Write a C program to ro read in a string from the user and print the string and print the length of the string read in a second string from the user and print the string and print the length of the string . compare the two string and print the output. .concatenate these two strings and print the new string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!