Thread: what is the meaning of this expreesion

  1. #1
    Banned
    Join Date
    Aug 2009
    Posts
    43

    what is the meaning of this expreesion

    i got this signature
    Code:
    void what(char *str, int flag){
    and inside it does
    Code:
    what(str-1, !flag);
    where flag is 0

    so whats !0 means

    or what !number is in terms of integer??

    (i know it from the if expressions and it has nothing to do with integers)

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by kakaroto
    so whats !0 means
    1

    Quote Originally Posted by kakaroto
    or what !number is in terms of integer??
    If number is 0, it results in 1, otherwise it results in 0.
    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

  3. #3
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    !0 means it's true(any non-zero quantity).
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  4. #4
    Banned
    Join Date
    Aug 2009
    Posts
    43
    Quote Originally Posted by laserlight View Post
    1


    If number is 0, it results in 1, otherwise it results in 0.
    so !8 is 0

    and !0 is 1

    i think you are mistaken because
    if we say differs false(0)

    it could be any number that differs 0
    4 ,8, 19
    etc..

    how do you know its 1

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by kakaroto
    how did you know its 1
    Because that is how operator! works in C.
    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

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    !x is basically short for
    (x) == 0 ? 1 : 0

    Any non-zero value is regarded as 'true', but the result of any boolean expression will always be 0 or 1
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by kakaroto View Post
    how do you know its 1
    Code:
    #include <stdio.h>
    
    int main() {
    
    	int x;
    	x=!0;
          printf("%d",x);// outputs 1
      }
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the meaning of " >> "
    By arian in forum C++ Programming
    Replies: 8
    Last Post: 03-30-2005, 10:40 AM
  2. Greatness, and its meaning
    By axon in forum A Brief History of Cprogramming.com
    Replies: 52
    Last Post: 11-18-2004, 10:53 PM
  3. The Meaning of Life: A Trick Question?
    By chix/w/guns in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2004, 07:53 PM
  4. The meaning of "Duh"
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 02-26-2003, 01:46 PM
  5. would you help me with Linked list, please?
    By unhwan in forum C Programming
    Replies: 1
    Last Post: 06-11-2002, 12:24 AM