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 6972093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:55:26+00:00 2026-05-27T16:55:26+00:00

In K&R Section 5.10, in their sample implementation of a grep -like function, there

  • 0

In K&R Section 5.10, in their sample implementation of a grep-like function, there are these lines:

while (--argc > 0 && (*++argv)[0] == '-')
    while (c = *++argv[0])

Understanding the syntax there was one of the most challenging things for me, and even now a couple weeks after viewing it for the first time, I still have to think very slowly through the syntax to make sense of it. I compiled the program with this alternate syntax, but I’m not sure that the second line is allowable. I’ve just never seen *‘s and ++‘s interleaved like this, but it makes sense to me, it compiles, and it runs. It also requires no parentheses or brackets, which is maybe part of why it seems more clear to me. I just read the operators in one direction only (right to left) rather than bouncing back and forth to either side of the variable name.

while (--argc > 0 && **++argv == '-')
    while (c = *++*argv)
  • 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-05-27T16:55:26+00:00Added an answer on May 27, 2026 at 4:55 pm

    Well for one, that’s one way to make anyone reading your code to go huh?!?!?!

    So, from a readability standpoint, no, you probably shouldn’t write code like that.

    Nevertheless, it’s valid code and breaks down as this:

    *(++(*p))
    

    First, p is dereferenced. Then it is incremented. Then it is dereferenced again.


    To make thing worse, this line:

    while (c = *++*argv)
    

    has an assignment in the loop-condition. So now you have two side-effects to make your reader’s head spin. YAY!!!

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

Sidebar

Related Questions

When I Jump to section 1 & 2 everything works fine, and the browsers
In section 10.4, The Definitive ANTLR reference tells you to override mismatch() & recoverFromMismatchedSet()
In K&R ANSI C book, section A.7.4.5 (Unary Minus Operator) it is stated: ...
I'm reading through K&R and came to the small section on register variables, and
I'm following the sample code in CFNetwork Programming Guide , specifically the section on
I have a government client that requires the legal 'section symbol' (§) in their
I've got a section of code that redirects users to a page when their
I recently implemented these tooltips on my website. They look great in Chrome &
I have a social network that has a blogs and questions section. There are
& has && . | has || . Why doesn't ^ have ^^ ?

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.