David Hautbois wrote: > Hi > I have an odd issue. > > > My function : > **************************************************************** > char * get_config_value (sqlite3 * db, char * config_name) {
[...] > configvalue = (char *) sqlite3_column_text(stmt, 0); [...] > return configvalue; > } > Why the variable content changes ?? > > Why the variable configvalue has not the same content ?? The variable has the same content (a pointer), but the pointer is invalid by the time your function returns it. You need to copy the *string*, not just a pointer to it. This is essentially the same issue that Igor described when he wrote: > Strings passed to the callback are valid only within the callback. As > soon as the callback returns, the memory may be deallocated or reused > for other purposes. If the callback wants to keep some strings around > beyond a single call, it should allocate its own memory and copy the > value over. It's vitally important when using C libraries that you read the documentation and avoid making any assumptions about the lifetimes of objects referenced by pointers. C++ wrappers can return std::string objects and avoid this issue (though even in C++ it's important to consider validity/lifetime issues for both pointers and iterators). -- James ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------