RE: Data Casting

"Stephen F. Booth" <[email protected]> Fri, 11 Jul 2003 09:30:31 -0400
Newsgroups gmane.comp.gcc.cgicc.general
Message-ID <001001c347b0$9d66ebd0$7d779a40@hades>
I guess you shouldn't pass a string object to a c function with varargs.
Use the c_str() function to get the data you want:

 sprintf(prog, 
  "lpr -P%s /tmp/print_web.tmp",prg_prn_sel->getValue().c_str());

> -----Original Message-----
> From: [email protected] [mailto:help-cgicc-
> [email protected]] On Behalf Of Marcos Araujo Sobrinho
> Sent: Tuesday, February 25, 2003 11:28 AM
> To: [email protected]
> Subject: [help-cgicc] Data Casting
> 
> Hi,
> 
> First, sorry about my poor english.
> 
> 
> I'm newbie in cgicc and i'm having some troubles with it.
> 
> I need to receive a value from a form, and then, call a system() with
> it.
> 
> ofstream print_tmp("/tmp/print_web.tmp");
> (*prg_arquivo).writeToStream(print_tmp);
> char prog[500];
> sprintf(prog, "lpr -P%s /tmp/print_web.tmp",prg_prn_sel->getValue());
> system(prog);
> 
> but when I try to compile, i'm getting this:
> 
> webprint.cpp: In function `int main(int, char **)':
> webprint.cpp:60: warning: cannot pass objects of type `string' through
> `...'
> 
> and when I run the program i'm getting this:
> 
> lpr -Pxô˜ë˜ô8úØúP /tmp/print_web.tmp
> 
> 
> What I can do to fix this?
> 
> Thanks for help, and again, sorry about my very bad english
> Marcos
> 
> 
> 
> _______________________________________________
> help-cgicc mailing list
> [email protected]
> http://mail.gnu.org/mailman/listinfo/help-cgicc