Re: pointers...

Discussion in 'C Programming' started by Zhang Lang, Jun 25, 2003.

  1. Zhang Lang

    Zhang Lang Guest

    Hi, Geo,

    I would like use the second way. Because it can protect the fields (or
    elements) of the "random" from being changed in the function.

    Do you know the differences from these two ways:

    int i;

    1) function(i);
    2) function(&i);

    And you can write a piece of codes to check it .

    I am a "rookie". If you find any mistake in what I said, pls let me know.

    George Zhang


    "geo" <geometrikal@hhoottmmaaiill> дÈëÏûÏ¢ÐÂÎÅ
    :...
    > hi all
    >
    > say if i had :
    >
    > struct random_struct {
    > .....
    > .....
    > .....
    > }
    >
    > struct random_struct random;
    >
    > and then i had a function which used this structure. What is the best
    > programming practice:
    >
    > void function(struct random_struct * r) {
    > .......
    > }
    >
    > function(&random);
    >
    > or:
    >
    > void function(struct random_struct r) {
    > .......
    > }
    >
    > function(random);
    >
    >
    > and why?
    >
    > Thanks
    > Ross
    > --
    > comp.lang.c.moderated - moderation address:

    --
    comp.lang.c.moderated - moderation address:
    Zhang Lang, Jun 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil
    Replies:
    1
    Views:
    643
    llewelly
    Sep 16, 2003
  2. muser
    Replies:
    3
    Views:
    759
    Ron Natalie
    Sep 18, 2003
  3. A
    Replies:
    3
    Views:
    453
    Alan Kelon
    Oct 29, 2003
  4. Xamalek
    Replies:
    7
    Views:
    685
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    668
Loading...

Share This Page