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;


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.

Recommended Answers

All 4 Replies

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.

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

Yes it returns size_t, and i agree with Caligulaminus.
If want to learn more about sizeof operator, check below link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.