Yes, but why did the loader only complain about "bar" being defined multiple times and not "foo"?
Type: Posts; User: newlearner
Yes, but why did the loader only complain about "bar" being defined multiple times and not "foo"?
@Spidey, yes I meant I made the typo while typing the post. Sorry for not being clear.
@Elysia, excellent trick. I was looking through some source code of other projects and found a way to make your...
Use the atoi function? And then just shift bits?
unsigned int hex = atoll(hexdata);
for (i = 0; i < 4; i++)
sprintf(data[i], "0x%x", (hex >> ((3-i) * 8)) & 0xff);
EDIT: changed atoi to...
Sorry my mistake....typo in writing out code. Thanks for catching that.
Hi,
I have a globals header that contains all my global variables and constants. The basic layout looks like this:
#ifndef _GLOBALS_H_
#define _GLOBALS_H_
int foo;
const int bar = 2;
Follow Spidey's suggestion...one tip I will give you is the atoi function which takes in a string like "32" and converts it to the int 32.
Thanks guys. Yeah, as many of you have guess the code I presented is basically how the offsetof macro is defined sometimes. I was just trying to figure out how it worked. Thanks for all those that...
Hi,
struct blah {
int a;
int b;
};
struct blah *tmp = (struct blah *) 0;
printf("%p\n", &tmp->b);