Hogyan kezeli a C++ tömböket. Hogyan tudhatod meg mekkora a tömb? Mi történik ha az indexben túl nagy számot adsz meg?
Forráskód:
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int szamok[]={7,4,2,9};
//int szamok[4];
//szamok[0]=8;
//cout<<szamok[1]<<endl;
int h=sizeof(szamok)/sizeof(int);
cout<<h<<endl;
for(int i=0;i<8;i++){
cout<<szamok[i]<<endl;
}
return 0;
}
Videó: