`

数据遍历

 
阅读更多

1.C/C++中求得数据长度并遍历

 

	double c[12] = {'a','b','c','d','e','f','g','h','i','j','k','l'};
	//totallong(96) = sizeof(c)求得数组长度 但由于本长度与类型有关所以 typelong(8) sizeof(*c)求得类型长度
	//所以数组长度为size = totallong / typelong
	//size = sizeof(c)/sizeof(*c);
	
	int size =  sizeof(c)/sizeof(*c);
	for (int i = 0; i < size; i++) {
	    cout << c[i] << endl;
	}

 

0
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics