#include <iostream> using std::cout; using std::endl; int main(){ int array1[10]; array1[0] = 100; int array2[10] = {201, 202, 203, 204, 205, 206, 207, 208, 209, 200}; int array3[10] = {301, 302, 303}; cout << "http://dev-microsoft.blogspot.com/" << endl << endl; cout << "Array without initializing, all elements contain junk value!" << endl; for(int i = 0; i < 10; i++){ cout << array1[i] << " "; } cout << endl << endl; cout << "Array with all element initialized." << endl; for(int i = 0; i < 10; i++){ cout << array2[i] << " "; } cout << endl << endl; cout << "Array with partial initialized, un-initialized elemented will be set 0." << endl; for(int i = 0; i < 10; i++){ cout << array3[i] << " "; } cout << endl << endl; system("PAUSE"); }
Thursday, January 26, 2012
Initializing array in C++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment