i have two c files
in the first file i have declared and initialised an array and i need to use the array in my second file also,how to use the same array in my second file......
i have two c files
in the first file i have declared and initialised an array and i need to use the array in my second file also,how to use the same array in my second file......
Look up the extern keyword, and examples of its usage. Google is your friend.
Declare an array in the second file using extern keyword.Code:// file01.c int array[3] = {1, 2, 3};Or create a header file for the first file and include in the second file.Code:// file02.c extern int array[3];
Code:// file01.h extern int array[3];Code:// file02.c #include "file01.h"
Last edited by DRK; 11-26-2012 at 04:15 AM.