Create a function removeWhite(const char *strl, char *str2) that removes all spa
ID: 3686654 • Letter: C
Question
Create a function removeWhite(const char *strl, char *str2) that removes all spaces inside str1 and stores the resulting string in str2. Create a function substring(const char *big, const char *small) that takes two strings as parameters and returns 1 if the string small is included in the string big (without using string.h functions strstr or strchr)Write a program (strProcessing.c) that uses the two functions you wrote. Your program should first ask the user to enter a string (possibly containing spaces). It should then use removeWhite to compute the new corresponding string without spaces and print it to the standard output. Next, your program should ask the user to enter two strings, read them and outputs one of the following statements accordingly: The string XXXX contains the string YYYY. The string XXXX does not contain the string YYYY. Where XXXX and YYYY are replaced by the actual strings entered by the user.Explanation / Answer
---------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<string.h>
int cmpstr(char s1[10], char s2[10]);
int main()
{
char arr1[10] = "Nodalo";
char arr2[10] = "nodalo";
printf(" %d", cmpstr(arr1, arr2));
//cmpstr() is equivalent of strcmp()
return 0;
}/ /s1, s2 are strings to be compared int cmpstr(char s1[10], char s2[10])
{
//strlen function returns the length of argument string passed
int i = strlen(s1);
int k = strlen(s2);
int bigger;
if (i < k)
{
bigger = k;
}
else if (i > k)
{
bigger = i;
}
else { bigger = i;
} //loops 'bigger' times
for (i = 0; i < bigger; i++)
{
//if ascii values of characters s1[i], s2[i] are equal do nothing if (s1[i] == s2[i])
} //else return the ascii difference
else
{
return (s1[i] - s2[i]);
}
} //return 0 when both strings are same //
This statement is executed only when both strings are equal return (0);
---------------------------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.