Original Post
Hey! I know I can pass a pointer to a function and change its value, but when i try to do it again with a function within the first function the value does not change.... example. file -> main.c file -> process.c file -> tools.c Is it possible? Am I crazy is this over the top? Doesn't work for me... This is merely an experiment to try to create reusable code in C. I'm trying to keep code in separate files to make it cleaner. Thanks.
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
int main(void) {
int *piece = 0;
int i = 0;
for ( i=0; i < 5; i++ ) {
change_Piece( &piece );
}
printf( "Piece - %d", piece );
return EXIT_SUCCESS;
}
#include <tools.h>
void change_Piece( int *piece )
{
addPiece( &piece );
}
void addPiece( int *num )
{
int t = *num;
t += 1;
*num = t;
}