Hi all,

in one of the header file I have declared

#define GPSINIT "version no"

I need to find where this string is stored in memory location. I tried to

test_string1 = &GPSINIT2STRING;

LOG_Write(test_string1,sizeof((int*)test_string1));
/*this func writes the result to a new text file*/

Also is it possible to get the value in hex?

thanks

in one of the header file I have declared

#define GPSINIT "version no"

That's not a variable. If it was, you could find out where the variable is quite easily. As you have it, there may be more than one of these here and there, so finding where "it" exists is difficult.

Solution: define a variable.

commented: 'bout time for another rep++ from Salem :) +6

That's not a variable. If it was, you could find out where the variable is quite easily. As you have it, there may be more than one of these here and there, so finding where "it" exists is difficult.

Solution: define a variable.

ok I am sorry but I need to find where 'version no' exists in memory. Is this possible?

I don't know the code you have. It is quite possible that it exists in 100 places. Or 1. Without the whole code, it cannot be determined. So at this point, your question has no answer.

Sure it's possible, but you're not making it easy.

What do you mean "exists"?

It exists by you using it.

Like printf( "The version is %s", GPSINIT ); or const char *ver = GPSINIT; or char temp[100]; strcpy( temp, GPSINIT ); All of them in their own way get the address of the start of that string.
Now as Dave says, whether that is always the same address depends on your compilers' approach to folding duplicate strings - which is an implementation defined behaviour.

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.