what is the meaning of this expreesion

This is a discussion on what is the meaning of this expreesion within the C Programming forums, part of the General Programming Boards category; i got this signature Code: void what(char *str, int flag){ and inside it does Code: what(str-1, !flag); where flag is ...

  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
    21,941
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,941
    Quote Originally Posted by kakaroto
    how did you know its 1
    Because that is how operator! works in C.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    !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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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, 09:40 AM
  2. Greatness, and its meaning
    By axon in forum A Brief History of Cprogramming.com
    Replies: 52
    Last Post: 11-18-2004, 09: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, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21