Hi frndz...

here's my doubt..
if i pass a decimal or hexadecimal integer to a function from my main function..and then have to decide in that function whether the argument is a decimal or hexadecimal value..how shud i go bout it??

for ex:

int main()
{
int count=2;
int x[]={0x620058, 0x665eaf};// or int x[]={123,44};
func(x,count);
return 0;
}

the func is....

void func(int x[],int count)
{
int a;
for(int i=0;i<count;i++)
a+=x;
}

here , how do i make sure that the integers passed in an array to the func() are in decimal or hexadecimal form???
remember it can only be passed as an integer array, not as a character array or string....

Recommended Answers

All 3 Replies

As far as I'm aware you can't tell as I believe they are both just translated to one type (e.g. hexadecimal or decimal) during compilation. I am not 100 percent sure of this so maybe you should look in a tutorial or book.

The compiler just translate it into binary. You could either, get the input
as hex, or decimal or octal.

You can't get the input as a number and determine if its decimal or hex.

Just get it as hex, and the convert it into decimal if you want or need to.

As far as I'm aware you can't tell as I believe they are both just translated to one type (e.g. hexadecimal or decimal) during compilation. I am not 100 percent sure of this so maybe you should look in a tutorial or book.

ya buddy...seems so..
searched a lot but cudnt get a satisfactory answer...
Thanx anyways!!

Be a part of the DaniWeb community

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