Welcome to HBH V2 ! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

C Add Function


Scar0ptics's Avatar
Member
0 0

I created a file within a Linux OS and used Nano to create the file. I named this file "Add.c" and compiled it by using "g++". I know some people may prefer other text editors, and that's fine.

1.) Create an AddOne function so that it correctly adds one to the value of x and prints:

X: 0 X: 1

#include <stdio.h>

int main(int argc, char ** argv){ int x = 0; printf("X: %d \n", x);

// put solution here

printf("X: %d \n", x); }


Scar0ptics's Avatar
Member
0 0

void Addone (int *x) { *x = *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.


_spartax_'s Avatar
Member
0 0

#include <stdio.h>

void inc(int*);

int main(int argc, char const* argv[]) { int foo = 0xDEAD; printf("%x\n", foo); inc(&foo); printf("%x\n", foo); return 0; }

void inc(int* x) { asm volatile("incl (%rdi)"); }


Scar0ptics's Avatar
Member
0 0

you got a smiley in your code man.