Thread: pointer notation

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    74

    pointer notation

    Just had a mini test worth a small percentage of our end of year grade. Wasnt overly happy with how it went the last part of the question was using pointer nonotation only to divide element 0 of an array by element 0 of another array and store them in a third array. And print the value to the screen.what would this look like.

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693
    Code:
    (function to take in 3 arrays)
    *(pointer3+0) = *(pointer1 + 0) / *(pointer2 +0);
    Something like this I would imagine. Depending on your thought processes.
    Code:
    int get_random_number(void)
    {
       return 4; //chosen by fair dice roll.
                 //guaranteed to be random
    }

  3. #3
    Registered User
    Join Date
    Oct 2014
    Posts
    74
    Thanks that's what I had : )

  4. #4
    Registered User
    Join Date
    Oct 2014
    Posts
    74
    another question about this what would this mean
    [code]
    *(pointer3+0) = *pointer1 + 0 / *pointer2 +0;
    [code/]

  5. #5
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Quote Originally Posted by alien1 View Post
    another question about this what would this mean
    Code:
    *(pointer3+0) = *pointer1 + 0 / *pointer2 +0;
    Basically you are dereferencing the array ( *pointer1), it is interpreted as a r-value. So what goes into pointer3 will be :

    Code:
       pointer3[0] = pointer1[0] + 0 / pointer2[0] + 0
    Also keep in mind where the division operator is.

    Code:
      pointer3[0] = pointer1[0] + ( 0 / pointer2[0] ) + 0
    A page listing operator precedence:

    C++ Operator Precedence - cppreference.com
    Last edited by Alpo; 12-02-2014 at 06:21 PM.
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer notation help!
    By colmulhall in forum C Programming
    Replies: 4
    Last Post: 03-23-2011, 09:15 AM
  2. Pointer equivalent to array notation
    By bekkilyn in forum C Programming
    Replies: 4
    Last Post: 12-06-2006, 08:22 PM
  3. Pls Help: Insertion sort using pointer notation
    By mack_ol in forum C Programming
    Replies: 1
    Last Post: 02-17-2002, 01:03 PM
  4. manipulation of strings using pointer notation
    By mlupo in forum C Programming
    Replies: 7
    Last Post: 10-08-2001, 12:23 PM
  5. problem with pointer notation in for-loop
    By sballew in forum C Programming
    Replies: 5
    Last Post: 09-30-2001, 06:28 PM