Question: Please modify my code according to the lab instructions thanks #include #include #include #include void getRandomString ( char str [ ] ) { int i;

Please modify my code according to the lab instructions thanks
#include
#include
#include
#include
void getRandomString(char str[]){
int i;
for (i =0; i 39; ++i){
str[i]='A'+(rand()%26);
}
str[i]='\0';
}
int getUserInput(char str[]){
printf("Enter a string: ");
scanf("%s", str);
int len = strlen(str);
if (len 2|| len >20){
return 0;
}
else {
return 1;
}
}
void strfilter(char s1[], char s2[], char ch){
int len1= strlen(s1), len2= strlen(s2), i, j;
for (i =0; i len1; ++i){
for (j =0; j len2; ++j){
if (s1[i]== s2[j]){
s1[i]= ch;
break;
}
}
}
}
int main(){
srand(time(NULL));
char s1[40], s2[40], s3[40];
char ch;
getRandomString(s1);
while (1){
strcpy(s3, s1);
if (getUserInput(s2)){
printf("Enter a replacement character: ");
scanf("%c", &ch);
strfilter(s3, s2, ch);
printf("s1={\"%s\"}
", s1);
printf("s2={\"%s\"}
", s2);
printf("c ={\"%c\"}
", ch);
printf("filtered s1={\"%s\"}
", s3);
printf("Do you want to try again: ");
scanf("%c", &ch);
if (ch !='Y' && ch !='y'){
break;
}
}
else {
printf("Error: Input string is too large
");
}
}
return 0;
}
Objective
To gain experience in the use of pointers and pure pointer notation.
Assignment
Modify lab 4B by replacing all array notations with pure pointer notations. However, arrays must still be defined. No subscripts in functions.
Run
The program multiple times with different user entered string and replacement characters showing all test cases and scenarios including invalid strings.
Turn In
Turn in source code and output file.
Please modify my code according to the lab

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 Programming Questions!