Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C (when compiled has no warnings) that: Opens a file called MyQualities.txt for writing. Repeatedly ... Reads a sentence from the

Write a program in C (when compiled has no warnings) that:

Opens a file called MyQualities.txt for writing.

Repeatedly ...

Reads a sentence from the keyboard (using fgets).

Checks if the sentences starts with "I am " (using strstr)

If it does, then extracts the substring starting at the 5th character, i.e., the substring containing the quality the person believes they possess. (using strncpy).

Concatenates the substring onto a growing string containing all such qualities, with a comma separator (using strncat - the growing string has a maximal length of 1024 characters).

Appends the substring to the MyQualities.txt file.

Stops looping when a string containing just a "." is entered (check using strcmp).

Outputs the grown string of qualities to the screen.

Opens the MyQualities.txt file for reading

Reads and echo the qualities from the file

Deletes the file

Here's what a sample run should look like (with the keyboard input shown in italics) ...

Please enter sentences, . to end. Hello everyone I am very clever Most people are not I am good looking too I am really good looking You are ugly I am confident . The qualities are very clever, good looking too, really good looking, confident. Confirming the saved qualities ... very clever good looking too really good looking confident

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions