Hi all, Thanks for the reply ! I was able to write this function successfully. This would lead me to my next question. Is there anyway to test if a memory address is valid or not without causing a segmentation fault and catching this maybe in a signal handler ? Is there a safe way in the same function " void * foo (char * addr)" to check that if the address contained in the string represented by "char * addr" is valid before returning it. Thank you ! Saurabh On Sun, Jul 26, 2009 at 4:14 AM, Eric Polino<aluink@xxxxxxxxx> wrote: > sure, you can just write a function that declares a void * and uses it as a > regular numeric type such as int or whatnot and parses the string > representation as a numeric value into that variable. You can do stuff the > same as you would with any other integer type, "x += 10; x -= 18;". So the > function would look something like > > void *foo(const char *addr){ > void *parsed_value = 0; > .... > /* Parse addr into parsed_value */ > .... > /* parsed_value == value_described_by(addr) */ > > return parsed_value; > } > > Parsing addr into parsed_value is left as an exercise to the reader ;) > > "None are more hopelessly enslaved than those who falsely believe they are > free." > --Goethe > > "Freedom is living without government coercion." > --Ron Paul (www.ronpaul2008.com) > > > On Sun, Jul 26, 2009 at 03:39, Saurabh Sehgal <saurabh.r.s@xxxxxxxxx> wrote: >> >> Hi all, >> >> I had a quick question: >> >> Let's say I design a function with the signature: >> >> void * foo( char * addr ) ; , >> >> where addr is a string that represents a valid memory address ... >> so the way someone can call this function is ... >> >> char * addr = "0xae456778" // assume this is a valid memory address on >> the machine >> foo( addr ) ; >> >> Is it possible to take this address in string form, and assign it to >> an actual pointer of void * type ? >> I want the function "foo" to return a pointer pointing to the memory >> location as indicated >> by the string passed in. >> >> Thank you ! >> >> Saurabh >> -- >> To unsubscribe from this list: send the line "unsubscribe >> linux-c-programming" in >> the body of a message to majordomo@xxxxxxxxxxxxxxx >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- Saurabh Sehgal E-mail: saurabh.r.s@xxxxxxxxx Phone: 647-831-5621 LinkedIn: http://www.linkedin.com/pub/1/7a3/436 -- To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html