0

I having problem of sizeof returning a hexadecimal value which I want it return decimal
here is my sample code:

#include <cstdlib>
#include <iostream>
#include "stringCascade.h"

using namespace std;

void StringCascade (void)
{
     unsigned char ucA[] = {0x02, 0x6F, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x04, 0xD4, 0x4A, 0x01, 0x00, 0x03, 0x03};
     int num = 16;
    

     cout<<endl;
     cout<<(int)sizeof(ucA)<<endl;
     cout<<dec<<(int)sizeof(ucA)<<endl;
     cout<<dec<<num<<endl;
}

why it will return a hex value? how can i get back integer value? i mean like size = sizeof(ucA), the variable "size" should store the size in decimal.

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by tajendra
1

sizeof() returns a binary value. Decimal and Hexadecimal are simply display values of those binary values to the user. If you see hex values it's because your cout has been told to display the value as hex.

0

Okey, then may i know what is the variable type sizeof return?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.