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.
--------------------------------------------------------------------------------------------------------------------------------------------------------
#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 stringStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started