Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program must be in C. Please make sure the program actually runs The program must take the word darn in a sentence and change

The program must be in C. Please make sure the program actually runs

The program must take the word "darn" in a sentence and change it to ****.

This is what I have so far. Thank you!

#include

int censor(char phrase[], int psize, char curses[], int csize)

{

int n;

int i;

int found = 0;

i = 0;

while(phrase[i] != '\0')

{

/** If the first letter matches **/

if(phrase[i] == curses[0])

{

int j;

j = 0;

int match;

match = 1; // match is true

while(curses[j] != '\0' && match == 1)

{

if(curses[j] != phrase[i+j])

{

match = 1; // match is false

}

}

if(curses[j] == '\0')

{

if(phrase[i+j] == ' ' || phrase[i+j] == '\0')

{

foul = 1;

int k;

k = 0;

while(k <= j)

{

phrase[i+k] = '*';

k = k + 1;

}

}

/** Skip to the next word **/

while(phrase[i] != ' ' && phrase[i] != '\0')

{

i = i + 1;

}

i = i + 1;

}

return 0;

}

}

int main()

{

int i =0;

/** Sets curse word **/

int csize = 5;

char curse[5] = "darn"; // the curse words

/** Variables and Function call to read in a phrase should be here**/

char str[1000];

printf("Please enter a phrase: ");

scanf(" %s", str);

printf("Your Phrase: ");

while(i == 0)

{

str[i] != '\0';

i = i +1;

printf(" %c", str[i]);

}

int strsize;

while(strsize ==0)

{

str[i] != '\0';

strsize = strsize +1;

}

}

int foul = censor(str[0], strsize, curse, csize);

if(1 == foul)

{

printf(" There was potty language in your phrase. It was censored. See below: ");

}

else

{

printf(" Your sentence was clean. Here is what you entered: ");

}

printf("%s ", str);

return 0;

}

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago