Thread: What is this syntax?

  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    97

    What is this syntax?

    Hi everyone,

    How this syntax is interpreted? This is like an if statement? If startup_event == BSP_EVENT_CLEAR_BONDING_DATA is true then p_erase_bonds will be true?

    Code:
    p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
    Nick

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    505
    The expression startup_event == BSP_EVENT_CLEAR_BONDING_DATA evaluates to 1 if the two values are equal, 0 if they differ.

    So parse-_bonds ends up with the value of either 1 or 0.

    It would be more normal to use an if or the "? :" syntax here, but it is valid C and you see assignmaents of relative operator conditions quite a bit in real code.
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    https://github.com/MalcolmMcLean


  3. #3
    Registered User
    Join Date
    Feb 2019
    Posts
    97
    Thanks!! This is what I was expecting!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with some syntax
    By Alexis in forum C Programming
    Replies: 2
    Last Post: 02-17-2013, 06:27 PM
  2. Array Syntax Versus Pointer Syntax
    By LyTning94 in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2011, 10:56 AM
  3. what must be syntax?
    By shwetha_siddu in forum Tech Board
    Replies: 15
    Last Post: 04-30-2008, 09:35 AM
  4. Syntax Help Please
    By misplaced in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2005, 07:47 AM
  5. About syntax and std::everything
    By Cobras2 in forum C++ Programming
    Replies: 13
    Last Post: 06-04-2003, 04:42 PM

Tags for this Thread