Skip to content

Latest commit

 

History

History

0x0E-function_pointers

0x0E. C - Function pointers

About

An introductory project on:

  • function pointers and how to use them
  • contents of a function pointer
  • what function pointers point to in the virtual memory

Requirements

  • Ubuntu 14.04
  • gcc 4.8.4

File Descriptions

Mandatory

function_pointers.h - header file for 0-print_name.c, 1-array_iterator.c, and 2-int_index.c.

0-print_name.c - function that prints a name using a function given as a parameter.

1-array_iterator.c - function that executes a function given as a parameter on each element of an array.

2-int_index.c - function that searches for an integer using a comparative function given as a parameter.

3-calc.h - header file for 3-main.c, 3-op_functions.c, and 3-get_op_func.c.

3-main.c - performs simple operations passed in as parameters.

3-op_functions.c - contains the following 5 functions:

  • int op_add(int a, int b) - returns the sum of a and b.
  • int op_sub(int a, int b) - returns the difference of a and b.
  • int op_mul(int a, int b) - returns the product of a and b.
  • int op_div(int a, int b) - returns the result of the division of a by b.
  • int op_mod(int a, int b) - returns the remainder of the division of a by b.

3-get_op_func.c - selects the correct function from 3-op_functions.c to perform the operation asked by the user.

Advanced

100-main_opcodes.c - prints the opcodes of its own main function up to a specified number of bytes.