Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
hi
secound code does not works
cuz when u declear an static array compiler should knows the dimention of that and in this condition the value of N is unknown in compile time until run time.
but in first code u use from precompiler expresion #define that is same as u write int H[100];
if u want to create an array with dynamic dimention use from new and delete operations.
int *H=NULL;
int N=100;
H=(int*) new int[N];
.
.
.
use from H like an array and when u dont need it any more. u should free memory of it:
in case 1, the compiler simply replace the N with the number defined and compiles the code, this is done during the precompilation phase of the compiler
in case 2, the compiler compiles the code as it is and i would recommend this because the code is more type safe this way.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.