Thread: fprintf syntax

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    141

    fprintf syntax

    I've a file as:

    +a
    -b
    +c
    +d
    .
    .
    .

    I want to print it into a file as +a -b +c +d ... into a file i.e convert \n into spaces!

    Could anyone please let me know the syntax?

  2. #2
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    Hmm, you seem to be creating a thread for every problem you encounter. Don't you think it would be better if you actually read through a book, or at least searched google for the answer? Or better yet, came up with a solution yourself?
    it's ironic considerate rarity patron of love higher knowledge engulfs me...

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    141
    Yes biv...I find this forum very helpful and thats the reason.I'm sorry if I'm bugging you.

  4. #4
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    Well, it doesn't bug me - I mean, the forums are here for help. But it just looks like you aren't even trying to learn. Obviously it's up to you.
    it's ironic considerate rarity patron of love higher knowledge engulfs me...

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    141
    I'm not getting much useful things from google. Also I've learnt much much more new techniques from this forum than google.
    I'm highly obliged to you guys here!

  6. #6
    Shibby willc0de4food's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    378
    why dont you read the file in as text, i.e.
    Code:
    FILE *fileptr;
    fileptr = fopen("yourfile.ext", "rt");
    and then just have a conditional. read in one char at a time and then check to see if it == '\n'. if it does, output a space to a string. if not, output the char to a string. after you've read in all of the file, output the string to it or a new file. whatever you choose you want.

    at least i believe that should work...


    also, you should look around cplusplus.com more often... http://www.cplusplus.com/ref/cstdio/fprintf.html
    Registered Linux User #380033. Be counted: http://counter.li.org

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM