ram address and pointers

I'm studying the C language on a guide with some exercises like this one on pointers. When i want to read the RAM address where is saved an int, why should i put 0x before %x?

 
printf ("Valore salvato all'indirizzo: 0x%x: %d\n",x,a);
The 0x is just a string literal, only the '%' is used by printf to escape. I image from this printf doesn't show base.

For instance %x could return FFFF, rather than 0xFFFF.

Here if my "kprintf" function for my OS:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void kprintf(const char* format, ...)
{
	va_list args;
	va_start(args,format);

	for(;*format!=0;++format)
	{
		if(*format == '%')
		{
			++format;
			if(*format == '\0') break;
			if(*format == '%') kputc(*format,-1,-1,TEXT);
			if(*format == 'x')
			{
				u32int hex = (u32int)va_arg(args,u32int);
				kputx(hex);
			}
			if(*format == 'd')
			{
				u32int i = (u32int)va_arg(args,u32int);
				kputs(itos(i),-1,-1,HEX);
			}
		}
		else
		{
			char c = *format;
			kputc(c,-1,-1,TEXT);
		}
	}
	va_end(args);
}
Topic archived. No new replies allowed.