Re: [Dev-C++] Invalid initializer for an array
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: RoGeR <le...@sp...> - 2000-10-10 06:34:46
|
Probably the compiler's fault. Why don't you try creating a function that handles that ? E.g. : template <class ARRAY_TYPE> void fill_array ( ARRAY_TYPE [] &arrary, int number_of_items, ARRAY_TYPE fill_value = 0 ) { for ( int i=0; i < number_of_items; i++ ) array[i] = fill_value; } } I know you said you didn't want the for thing... but making it a function becomes really easy to use : fill_array ( distribution, 5, 0 ); Byezzz ----- Original Message ----- From: Richard P. Evans <ev...@ma...> To: <dev...@li...> Sent: Tuesday, October 10, 2000 06:07 AM Subject: [Dev-C++] Invalid initializer for an array > Why do I get an "invalid initializer" message for the following line in my > program? > > int distribution[5] = (0); > > It seems the only thing that works to initialize an array is a "for" > statement. Does anyone have an answer? The above line is by the book and > should work. Or is this a software bug? Some how I doubt that. > > Richard Evans > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > http://lists.sourceforge.net/mailman/listinfo/dev-cpp-users > |