Thread: need help explaining proper use of pointers

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    4

    need help explaining proper use of pointers

    I need an explanation of correct use of pointers within functions.

    say i had a structure like this:

    Code:
    #include <stdio.h>
    #include "my.h"
    
    
    int main(void)
    {
    int length, width, customerdiscount, area;
    double costpersquarefoot, carpetcharge, laborcharge, installedpricecharge, discountcharge, subtotalcharge, taxcharge, totalcharge;
    
    read_data(&length, &width, &customerdiscount, &costpersquarefoot);
    
    calculate_values(length, width, customerdiscount, costpersquarefoot, &area,
                              &carpetcharge, &laborcharge, &installedpricecharge,
                              &discountcharge, &subtotalcharge, &taxcharge, &totalcharge);
    
    printresults(length, width, area, carpetcharge, laborcharge, installedpricecharge,
                        discountcharge, subtotalcharge, taxcharge,   totalcharge, costpersquarefoot);
    
    
    return 0;
    }

    when I call these functions. the first calls no other functions, the second calls 3, and the print calls 2... if they are going to change in the function i use *variablename, if not then its variablename? also when a function looks like this:

    void calculate_total (double* variable1, double* variable2, double variable3, double variable4,)
    {
    variable1 = variable3 * variable4;
    variable2 = variable3 + variable4;
    return;
    }
    how do i refer to it when i bring it back into main to use with all of the other functions?
    Last edited by dgilroy1210; 09-20-2011 at 04:15 PM. Reason: adding detail

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what's your actual question? Pointers in C - Tutorial - Cprogramming.com


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    And for a more detailed description: Prelude's Pointer Tutorial
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help in explaining the program
    By jazzz in forum C Programming
    Replies: 2
    Last Post: 05-23-2006, 12:42 AM
  2. need help explaining this code
    By lastresort in forum C++ Programming
    Replies: 4
    Last Post: 02-02-2005, 04:46 PM
  3. Explaining What This Code Does
    By Geolingo in forum C++ Programming
    Replies: 3
    Last Post: 03-29-2004, 12:19 PM
  4. I need help explaining something...
    By deathstryke in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-08-2003, 12:02 PM
  5. need graphics.h explaining.
    By will bushnell in forum C Programming
    Replies: 17
    Last Post: 03-28-2002, 11:18 PM