Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language: Implement function char *delete_comments(char *input) that removes C comments from program stored at input . input variable points to dynamically allocated memory.

In C language:

Implement function char *delete_comments(char *input) that removes C comments from program stored at input. input variable points to dynamically allocated memory. The function returns pointer to the polished program. You may allocate a new memory block for the output, or modify the content directly in the input buffer.

Youll need to process two types of comments:

  • Traditional block comments delimited by /* and */. These comments may span multiple lines. You should remove only characters starting from /* and ending to */ and for example leave any following newlines untouched.

  • Line comments starting with // until the newline character. In this case, newline character must also be removed.

The function calling delete_comments only handles return pointer from delete_ comments. It does not allocate memory for any pointers. One way to implement delete_comments function is to allocate memory for destination string. However, if new memory is allocated then it must be released after use.

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions