Declaring objects on the stack



Is there a way to declare a GString object on the stack and then pass a 
reference to that object to an initialization method? For example:

GString str, *ptr;
ptr = g_string_assign(&str, "foo");

Of course, I realize that the above is not valid because g_string_assign 
expects cooked values in &str whereas values declared on the stack are likely 
to contain garbage. So is there some other method which has the purpose of 
initializing &str without allocating memory for the object on the heap?

Marc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]