Thread: fprintf data to string

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310

    Red face fprintf data to string

    Hi all!

    I found a good source and I'm editing it.
    My only problem is that the source uses fprintf.
    Code:
    fprintf(file, "%d", i);
    How can I acces file data so I can parse it as string?
    Or convert file into a C-string?

    Thanks!
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, you want the number output to a string, rather than a file, is that it?

    You can use "sprintf(str, "%d", i)" for that, if you like.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    I thought in that, but the thing is that uses something like this:
    Code:
    FILE *in = stdin, *out = stdout;
    in = fopen(pszFile, "rb");
    in = stdin;
    _setmode(_fileno(in), _O_BINARY);
    for (j = 0; j < sizeof signature; j++) {
         fprintf(out, hexfmt, signature[j]);
    }
    ///...
    BTW: Is md5 code that I found
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    sprintf(). matsp is right.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. ........ed off at functions
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-29-2002, 09:37 PM