Thread: Amperstands! Confusion. And Jargon.

  1. #1
    Registered User
    Join Date
    Aug 2006
    Location
    Edinburgh, Scotland
    Posts
    2

    Amperstands! Confusion. And Jargon.

    I would greatly appreciate if someone could help me out with just a few simple questions.

    What is the difference between (a & b) and (a && b)?
    What exactly is ment by "predefined loop constructs"?
    How would I go about writing a section of code to take a stream of characters from the keyboard as input and filter out the spaces? I'm not looking for code here, just a tip in the write direction.

    I would be very grateful if someone could help.
    Thanks.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >What is the difference between (a & b) and (a && b)?
    The former represents a bitwise AND, the latter represents a boolean logical AND.

    >What exactly is ment by "predefined loop constructs"?
    Can you provide the context?

    >How would I go about writing a section of code to take a stream of characters
    >from the keyboard as input and filter out the spaces?
    Test for a space and ignore it if you find one:
    Code:
    while more characters
      read a character
      if not a space
        process
    loop
    My best code is written with the delete key.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Homework questions?

    My hints would be:
    1. bitwise is not logical
    2. Read your textbook
    3. Overloaded operator>> can do formatted input
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    1) Bitwise vs. Logical AND

    http://msdn2.microsoft.com/en-us/library/z0zec0b2.aspx
    http://msdn2.microsoft.com/en-us/library/c6s3h5a7.aspx

    2) In what context was this phrase used.

    3) string s,t; while(cin >> t) s += t;

    That filters all whitespace. The string t could also be used as a token not containing whitespace if that is what you wanted.

    Edit: That's just ridiculous. Haha.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Location
    Edinburgh, Scotland
    Posts
    2

    Cheers

    Thanks much, that's a great help.
    In reply to the context: I don't have Any i'm afraid. I'm doing a uni tutorial and i'm just not sure exactly what i'm being asked.
    Cheers again.

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I'm doing a uni tutorial and i'm just not sure exactly what i'm being asked.
    I doubt the question is nothing more than what you gave us. Show us the complete question.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed