From bug-octave-request at bevo dot che dot wisc dot edu Thu Mar 12 17:22:21 1998 Subject: String arguments to dynamically linked functions From: "John W. Eaton" To: Markus Svensen Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 12 Mar 1998 17:22:18 -0600 (CST) On 12-Mar-1998, Markus Svensen wrote: : I try to pass a string constant to a dynamically linked C++ function, : to be used as a filename. Unfortunately, it seems as if under certain : circumstances, this string constant get muddled up somewhere on the : way. : : Repeat-By: : --------- : : To illustrate the problem I've written another (much smaller) function: : : #include : #include : : DEFUN_DLD (dummy, args, , : "The `dummy'.") : { : octave_value_list retval; : : /* extract filename from argument list */ : string fname = args(0).string_value(); : : fprintf(stderr, "Filename: %s\n",((char*) fname.data())); I think this is the problem. If you want to extract a NUL-terminated string from a C++ string object, I think you need to use the string::c_str() method, not string::data(). Thanks, jwe