![Initializing array in C++ Initializing array in C++](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUmruvgTkxKi_BawKSwYN194H1LAM9AEibXXPz4f-rv86kCs6Mkun7WXMZZpWYRRwKO8qAP4e9yBPAb5hyhnaWKKXVvOjfjm9O2ssOOiOWjrnlSxtmvhNj3uhT3flM71XT_du_CnH-Xac/s400/testArray_01.png)
#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"); }
No comments:
Post a Comment