Results 1 to 8 of 8

Thread: [Resolved] Is there a better way?

Threaded View

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] Is there a better way?

    I just spent forever finding a way to do this:

    Code:
    #include <iostream>
    using namespace std;
    
    double *incArray(double *arr);
    
    int main() {
        double *vars;
    
        for (int i = 0; i < 4; i++) {
            vars = incArray(vars);
    
            vars[i] = i;
            cout << vars[i] << endl;
        }
        
        cout << endl << "After: " << endl << endl;
    
        for (i = 0; i < 4; i++) {
            cout << vars[i] << endl;
        }
    
        return 0;
    }
    
    double *incArray(double *arr) {
        
        double *arrtemp = arr;
    
        arr = new double[sizeof(arr)];
    
        for (int i = 0; i < sizeof(arrtemp); i++) {
            arr[i] = arrtemp[i];
        }
    
        return arr;
    
    }
    Is that good or is there a better way?
    Last edited by The Hobo; Nov 12th, 2002 at 12:09 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width