Programing in C question, can some one help me with this code without using the
ID: 3687878 • Letter: P
Question
Programing in C question, can some one help me with this code without using the string library. Part II: Lab Assignment Getting started Change into the cse220 directory. Create a new directory called lab12. Change into the new directory. Implement the program below in your lab12 directory String manipulation Create a function removeWhite(const char *str1, char "str2) that removes all spaces inside str1 and stores the resulting string in str 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>
void removeWhite(const char *str1,char *str2){
while(*str1!=''){
if(*str1!=' '){
*str2 = *str1;
str2++;
}
str1++;
}
*str2='';
}
int substring(const char *big, const char *small){
int small_len=0;
while(*(small+small_len) !='')
small_len++;
while(*big!=''){
if(*big == *small){
int j=0;
while(*big !='' && *big == *(small+j) && j<=small_len){
big++;
j++;
}
if(j==small_len)
return 1;
}
big++;
}
return 0;
}
int main(){
char str[100];
char str1[100],str3[100];
char str2[100];
printf("Enter a string to test removeWhite:");
scanf("%[^ ]",str);
removeWhite(str,str1);
printf("The string with all white spaces removed is %s ",str1);
printf("Enter a larger string:");
scanf("%s",str2);
printf("Enter a smaller string:");
scanf("%s",str3);
int value = substring(str2,str3);
if(value)
printf("The string %s contains the string %s",str2,str3);
else
printf("The string %s does not contains the string %s",str2,str3);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.