Syntax Style

This is a discussion on Syntax Style within the C Programming forums, part of the General Programming Boards category; Hi, just a question of style, am I right in thinking these two are the same *(my_array) = NULL; my_array[0] ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    93

    Syntax Style

    Hi,

    just a question of style, am I right in thinking these two are the same

    *(my_array) = NULL;
    my_array[0] = NULL;

    and these two

    *(my_array + i) = NULL;
    my_array[i] = NULL;


    I am used to seeing the second of each pair, but have only just spotted the other two in a program I am reading at present;



    tia,

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    They are the same. The first in each pair directly works with the pointer that is the beginning of the array. The second in each pair works directly with array subsripting. The first is an example of pointer arithmitic.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    93
    thanks velius


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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