Question
can someone fix the errors ? //manipulating V2 #include manipulating.h void manipulating() { //printing on screen.. printf(*** Start of Concatenating Strings Demo *** ); //variables
can someone fix the errors ?
//manipulating V2
#include "manipulating.h"
void manipulating() {
//printing on screen..
printf("*** Start of Concatenating Strings Demo *** ");
//variables of type char arrays/string declaration..
char string1[80];
char string2[80];
char compare1[256];
char compare2[256];
int result;
//Infinite loop to concate two user inputted string until first string is q..
while (true) {
//taking string 1 from user..
printf("Type the 1st string (q - to quit): ");
gets(string1);
//Checking for input if it is q then break the infinite loop
if (strcmp(string1, "q") == 0)
break;
//taking string 2 from user..
printf("Type the 2nd string: ");
gets(string2);
//Concate both the string
strcat(string1, string2);
//printing output..
printf("Concatenated string is %s ", string1);
}
printf("*** End of Concatenating Strings Demo *** ");
printf("*** Start of Comparing Strings Demo *** ");
while (true) {
printf("Type the 1st string to compare (q - to quit) : ");
gets(compare1);
if (strcmp(compare1, "q") == 0) break;
printf("Type the 2nd string to compare: ");
gets(compare2);
result = strcmp(compare1, compare2);
if (result < 0)
printf("1st string is less than 2nd ");
else if (result == 0)
printf("1 string is equal to 2nd ");
else
printf("1st string is greater than 2nd ");
printf("*** End of Comparing Strings Demo *** ");
}
}
prinf("***Start of Searching Strings Demo *** "); The errors start from here, everything on the top is working properly
char big_string[80];
char sub_string[80];
char* address;
while (TRUE) {
printf("Type the big string (q - to quit): ");
gets(big_string);
if (strcmp(big_string, "q")-- 0) break;
printf("Type the substring: ");
gets(sub_string);
address = strstr(big_string, sub_string);
if (address != NULL)
printf("Found at %u position ", address - big_string);
else
printf("Not Found ");
}
printf("***End of Searching Strings Demo *** ");
Step 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