Fill n

From kangssu
Jump to: navigation, search
fill_n
int testArray[10][10] = {0,};
fill_n(*testArray, 4, 5);
for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
        cout << testArray[i][j] << " ";
    }
    cout << endl;
}
fill_n(*testArray, 10*10, 5);
for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
        cout << testArray[i][j] << " ";
    }
    cout << endl;
}

If testArray is declared that int testArray[10];

fill_n(testArray, 10, value);

You can use it as above. In addition, You just add '*' to variable, as increasing array dimension.

hash_function_c