Thread: Combine code into a Single statement

  1. #1
    Registered User
    Join Date
    Dec 2003

    Combine code into a Single statement

    I am supposed to write a single statement that will save Sara and George into a text file called cppdata.txt using fprintf() and both fname(sara) and lname(george) are left justified and fname has 21 spaces and lname has 31 spaces.

    This is what I have so far:

    Not much but that is why I am asking for help!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    So you were told to use fprintf(), but you used fwrite()

    How about
    fprintf( fptr, "%20s%20s\n", "sara", "george" );
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Also, add at least the rest of the parameters so we have something to go on.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 23
    Last Post: 04-20-2009, 07:35 AM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 05:39 PM
  3. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 01:33 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM