Donate to us via Paypal!
I'd prefer to die standing, than to live on my knees - Che Guevara
Sunday, February 28, 2021
Navigation
Home
 Find:
 Information:
Learn
Communicate
Submit
Shop
Challenges
 Exploit:
 Programming:
 Think:
 Track:
 Patch:
 Other:
 Need Help?
Other
Members Online
Total Online: 124
Guests Online: 124
Members Online: 0

Registered Members: 133756
Newest Member: Cleaners01
Latest Articles

View Thread

HellBound Hackers | Computer General | Programming

Author

C Add Function with an Array

Scar0ptics
Member



Posts: 229
Location: ∆ P®0X¥ W0R|D ∆
Joined: 19.11.13
Rank:
Mad User
Posted on 16-11-16 00:58
Create an AddOneToAll function so that it correctly adds one to each element in an array with 5 elements: Compile your code with a Linux compiler and execute the output file. "./"

Output:
10 20 30 40 50
11 21 31 41 51
overlay-network.ddns.net
Author

RE: My Solution

Scar0ptics
Member



Posts: 229
Location: ∆ P®0X¥ W0R|D ∆
Joined: 19.11.13
Rank:
Mad User
Posted on 16-11-16 00:59
int main (int argc, char **, argv) {

int array [5];
addOneToAll(array, 5);
}
void addOneToAll ( int * array, int count) { //add one to all

for (int x = 0; x<count; x++) {
array[x] = array [x] + 1;

}

// I understand that there are other ways of doing this and I am open to all constructive criticism, but before you comment please consider that this code is written so the built-in Linux compiler (g++) can understand it.

Edited by Scar0ptics on 17-11-16 14:05
overlay-network.ddns.net