Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C: How to fix the code below so it remove the char from the original string not just print the other char. #include //Header

In C: How to fix the code below so it remove the char from the original string not just print the other char.

#include //Header Files

int main() { void rmchr(char[],char); //Function Declaration String,Character passing into function

char s1[]= "abracadabra"; //s1 to abracadabra char s2[]= "abracadabra"; //s2 to abracadabra char s3[]= "abracadabra"; //s3 to abracadabra char s4[]= "aaaa"; //s4 to aaaa char s5[]= "aaaa"; //s5 to aaaa printf("String\t\tCharacter\tAnswer "); printf("%s\t",s1); //Printing String Before Passing rmchr(s1,'a'); //Passing String and Character to remove into rmchr function

printf("%s\t",s2); //Printing String Before Passing rmchr(s2,'b'); //Passing String and Character to remove into rmchr function

printf("%s\t",s3); //Printing String Before Passing rmchr(s3,'n'); //Passing String and Character to remove into rmchr function

printf("%s\t\t",s4); //Printing String Before Passing rmchr(s4,'a'); //Passing String and Character to remove into rmchr function

printf("%s\t\t",s5); //Printing String Before Passing rmchr(s5,'n'); //Passing String and Character to remove into rmchr function

return 0; }

void rmchr(char str[],char ch) //Function Definition { char *p; //Pointer Variable p=&str[0]; //Storing address of First character of String in *p printf("%c\t\t",ch); //Printing Character to remove while(*p!='\0') //Loop for iterating String { if(*p!=ch) { //Checking if Character is not equal to each character printf("%c",*p); //Prints that unequal character } p++; //Address Increment of *p }

printf(" "); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

2. Why?

Answered: 1 week ago

Question

1. Where do these biases come from?

Answered: 1 week ago