Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9019047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:40:57+00:00 2026-06-16T04:40:57+00:00

This is about the comment deletion program in Kernighan and Ritchie (number 1-23 p

  • 0

This is about the comment deletion program in Kernighan and Ritchie (number 1-23 p 34 ANSI eidtion). The following is my solution.

http://pastebin.com/Fu9C94fV

The program works fine with most C programs, deleting comments. However, in some programs with comments that end with multiple asterisks (**/), it poses problems (does not read through). One such example is this one :

http://pastebin.com/J8EQrwve

However, it works with this program, despite the fact that it has a similar comment at the beginning:

http://pastebin.com/thWKvDS7

So what do you think is causing the comment deletion program to behave this way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:40:58+00:00Added an answer on June 16, 2026 at 4:40 am

    When you hit a * in comment state, you read the next character to see if it’s a /. This consumes that character, so it won’t be checked on the next iteration.

    So:

    /*  **/
        12
    

    sees the * at 1, reads the * at 2, stays in comment mode, and continues with the /. Whereas:

    /* ***/
       123
    

    sees the * at 2, reads the * at 2, continues, then reads the * at 3 and finds a / following and drops out of comment mode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading a comment about server architecture. http://news.ycombinator.com/item?id=520077 In this comment, the person
UPDATE: For anyone else wondering about this, check out the comment at http://www.php.net/manual/en/function.imagecreatefromstring.php#31178 I
While reading proggit today, I came upon this comment in a post about how
In the API result (http://developers.facebook.com/docs/reference/fql/link_stat/) there are two counts about comments: comment_count : The
I am confused by the following comment about TF-IDF and Cosine Similarity . I
I got some grief about this in a comment I posted the other day,
I am building an in-line SQL query (no need to comment about this I
When reading through parfib.hs code on github, I saw this comment about memory allocation
I am talking about this line of code <link rel=alternate type=application/rss+xml title=example.com &raquo; Comments
I was reading this site about the clojure web stack: http://brehaut.net/blog/2011/ring_introduction and it has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.