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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:11:06+00:00 2026-05-26T13:11:06+00:00

The Practice of Programming book says: One of the most serious problems with function

  • 0

The Practice of Programming book says:

One of the most serious problems with function macros is that a parameter that
appears more than once in the definition might be evaluated more than once; if the
argument in the call includes an expression with side effects, the result is a subtle bug.
This code attempts to implement one of the character tests from :

#define isupper(c) ((c) >= 'A' && (c) <= 'Z')

Note that the parameter c occurs twice in the body of the macro. If i supper is called
in a context like this,

while (isupper(c = getchar()))

then each time an input character is greater than or equal to A, it will be
discarded and another character read to be tested against Z.

I do not understand how a char greater >= A can be discarded.

  • 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-26T13:11:07+00:00Added an answer on May 26, 2026 at 1:11 pm

    Since macro definitions are expanded textually into the program before the actual compilation,

    isupper(c = getchar())
    

    would expand to

    ((c = getchar()) >= 'A' && (c = getchar()) <= 'Z')
    

    which by the short-circuiting rule for && calls getchar twice iff it returns >= 'A' the first time and assign c the value returned by the second call.

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

Sidebar

Related Questions

I agree, that programming against interfaces is a good practice. In most cases in
I am currently in a job where we practice serious pair programming on windows
I'm learning C++ and the book I'm reading (The C++ Programming Language) says to
I'm using the book Programming Principles and Practice using C++ to learn programming and
What do you think about this programming practice: - I need to execute one
I'm doing the exercises in Stroustrup's new book Programming Principles and Practice Using C++
I understand that this is bad programming practice and redundant coding but I am
I was wondering what would be the best programming practice for jQuery. Most jquery
I'm currently learning c++ with the book Programming: Principles and Practice Using C++ from
Just wondering if the following is considered to be good programming practice or not?

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.