Pointer to unsigned int question

C

Chad

And I quote the following URL...


http://qna.indiatimes.com/Programmi...e_pointer_to_unsigned_int_in_C_language?.html

"Why it is not possible to create pointer to unsigned int in C
language?"

"The variable the holds the address (the pointer) is not interested if
the value at the address it stores is signed or unsigned. One thing is
sure: it must store an int, careless if it is signed or unsigned."

Is this wrong? Just curious because I can create a pointer to unsigned
int. Here is what I mean..

[cdalten@localhost oakland]$ more us.c
#include <stdio.h>

int main(void)
{
unsigned int a = 5;
unsigned int *b = &a;

printf("The value of b is: %u\n", *b);

return 0;
}
[cdalten@localhost oakland]$ gcc -Wall us.c -o us
[cdalten@localhost oakland]$ ./us
The value of b is: 5
[cdalten@localhost oakland]$
 
M

Morris Keesan

And I quote the following URL...


http://qna.indiatimes.com/Programmi...e_pointer_to_unsigned_int_in_C_language?.html

"Why it is not possible to create pointer to unsigned int in C
language?"

"The variable the holds the address (the pointer) is not interested if
the value at the address it stores is signed or unsigned. One thing is
sure: it must store an int, careless if it is signed or unsigned."

Is this wrong?

Yes, it's absolutely wrong. The premise of the question is wrong, because,
as you point out, it *is* possible to create an (unsigned int *) in C.
And the explanation is total nonsense.
 
J

James Kuyper

Chad said:
And I quote the following URL...


http://qna.indiatimes.com/Programmi...e_pointer_to_unsigned_int_in_C_language?.html

"Why it is not possible to create pointer to unsigned int in C
language?"

"The variable the holds the address (the pointer) is not interested if
the value at the address it stores is signed or unsigned. One thing is
sure: it must store an int, careless if it is signed or unsigned."

Is this wrong? Just curious because I can create a pointer to unsigned
int. Here is what I mean..

Of course you can; the premise of the question is false. One possibility
is that the author had no understanding of what he was talking about.
Another possibility is that the question was accidentally worded
incorrectly.

However, since the question was described as having come from an
interview (presumably, a job interview?), there's a third possibility:
perhaps the purpose of the question was to determine whether the
interviewee had enough courage to tell the interviewer that the question
didn't make sense. Whether having that courage would count for you, or
against you, would depend upon the interviewer.
 
R

Richard Bos

Chad said:
And I quote the following URL...
http://qna.indiatimes.com/Programmi...e_pointer_to_unsigned_int_in_C_language?.html

"Why it is not possible to create pointer to unsigned int in C
language?"

"The variable the holds the address (the pointer) is not interested if
the value at the address it stores is signed or unsigned. One thing is
sure: it must store an int, careless if it is signed or unsigned."

Is this wrong?

Wrong? It's not even English...

But yes, it's wrong. It starts asking a wrong question and ends up
giving a worse answer.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top