How do I determine the byte values of an array?
The function sizeof() determines the size right? not the actual byte values.
Is there a function in determining byte values?
let say we have this code..
1 2 3 4 5 6 7 8 9 10 11 12
int i, helLen, byteVal;
char detByte[100];
string hello = "Hello"
sprintf(detByte, "%s", hello);
helLen = strlen(hello);
for(i=0;i<helLen;i++){
//insert a "function" that determine byte value per character
byteVal[i] = function(detByte[i]);
}
Thanks for the help.
The function sizeof() determines the size right? not the actual byte values.
sizeof actually determines the number of bytes. If you're working with a char array it happens that it also returns the number of elements because in most compilers it's sizeof(char)==1.
Consider this example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
usingnamespace std;
int main()
{
long array[10];
//this should say 4 (or more)
cout << "sizeof(long)=" << sizeof(long) << endl;
//this should say 40 (or more)
cout << "sizeof(array)=" << sizeof(array) << endl;
//this should say 10
cout << "sizeof(array)/sizeof(long)=" << sizeof(array)/sizeof(long) << endl;
cin.get();
}