Welcome, Guest. Please login or register.

Author Topic: printf output to string possible ?  (Read 3159 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
printf output to string possible ?
« on: September 10, 2005, 12:05:55 PM »
Hi. Is there a way that one can have the output of printf() put into a string instead of stdout ? I know there's a function to change the output stream but it requires a file or handle to be passed IIRC...
I have done a function that does this but it's a bit limited on the types it uses, I thought that maybe printf() could be used for this also....
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: printf output to string possible ?
« Reply #1 on: September 10, 2005, 12:28:53 PM »
@Thomas

Sounds great :-)
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: printf output to string possible ?
« Reply #2 on: September 10, 2005, 02:49:35 PM »
@Piru
"(void (*)(void))"

Wouldn't a simple cast to void work here? I don't get it, it's not even a function.. :-?

@CrazyProg

Yeah that's cool, but I'm allocating the space dynamically after checking the size with strlen().

\\"We made Amiga, they {bleep}ed it up\\"
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2871
    • Show all replies
Re: printf output to string possible ?
« Reply #3 on: September 11, 2005, 11:05:34 AM »
Ahhh... ok.  :-)
\\"We made Amiga, they {bleep}ed it up\\"