Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

I AM NOT GOOD AT PROGRAM

Name: Anonymous 2009-10-31 17:31


#include <iostream>

int *modi (int *array)
{
    int *start = array;
   
    for (int x = 0; x < 10; x++)
    {
        array[x] = x;
    }
   
    return start;
}
   

int main ()
{
    int arr[10] = { 0 };
   
    for (int x = 0; x < 10; x++)
    {
        std::cout << arr[x];
    }
   
    modi (arr);
   
    for (int x = 0; x < 10; x++)
    {
        std::cout << arr[x];
    }
   
    std::cout << "niggers";
   
    return 0;
}


So I just wrote this. I know what it does, and I know that it works, but I don't know how it works.
int *start dereferences, but the value is undefined, and oh god how the fuck did I make this compile.
Please help.

Name: Anonymous 2009-10-31 19:44

>>1
you don't need to copy array to start.
Just return array after you've done the mod function.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List