-1

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....

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by ayan2587
0

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.

0

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.

0

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!!

This topic has been dead for over six months. 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.