Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created August 3, 2016 22:26
Show Gist options
  • Save wohhie/ab4e148b0ee0e9c15b7a81896e42d370 to your computer and use it in GitHub Desktop.
Save wohhie/ab4e148b0ee0e9c15b7a81896e42d370 to your computer and use it in GitHub Desktop.
Find Array Size & Size of the int value.
//find array size
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
//processoing...
void search() {
//list of data
int dataList[] = {
911,
212,
92,
1221,
1231,
3,
242,
19
};
int counter = 0;
int dataSize = sizeof(dataList) / sizeof(dataList[0]);
int find = 912;
int length = (int)(log10(find) + 1);
cout << "\nArray Size: " << dataSize << endl;
cout << "finiding elm length: " << length << endl;
for (int i = 0; i < dataSize; i++) {
}
cout << counter << endl;
}
int main() {
search();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment