Results 1 to 15 of 15

Thread: printf itself

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    53

    Default Re: printf itself

    Quote Originally Posted by wysota View Post
    But it doesn't say what you need it for
    I don't understand 'for': I need it to write a program that print its code. Have you see in the example link how cout.form is used? Is there a similar function that work as it?
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: printf itself

    Quote Originally Posted by mickey View Post
    I don't understand 'for': I need it to write a program that print its code.
    Is it just for fun? For school? For any practical use? I'm just curious.

    Is there a similar function that work as it?
    try std::string and its sprintf method (I think it has one). Then you can redirect the result to cout.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    53

    Default Re: printf itself

    OK!! It is just for fun. But I think your target in your question was another. Is it so? I'm curious too.....
    But I don't find fprintf method in string; but if it's used to write on a file as said before it's a cheat...
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: printf itself

    Quote Originally Posted by mickey View Post
    OK!! It is just for fun. But I think your target in your question was another. Is it so? I'm curious too.....
    No... I don't think so.
    But I don't find fprintf method in string; but if it's used to write on a file as said before it's a cheat...
    sprintf not fprintf. You sprintf what you want to printf into a string and then "printf" it (by redirecting) to cout

    Something like:
    Qt Code:
    1. std::string str;
    2. str.sprintf("Format %s", "xyz");
    3. std::cout << str << std::endl;
    To copy to clipboard, switch view to plain text mode 

    Just make sure std::string::sprintf really exists.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    53

    Default Re: printf itself

    it doesn't exist as part of string....(at least in .net); but I wonder where's the "form" method....
    Regards

Similar Threads

  1. Redirect printf to QTextEdit?
    By Randulf in forum Qt Programming
    Replies: 9
    Last Post: 12th October 2006, 14:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.