Combine code into a Single statement

This is a discussion on Combine code into a Single statement within the C Programming forums, part of the General Programming Boards category; I am supposed to write a single statement that will save Sara and George into a text file called cppdata.txt ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    2

    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:

    Code:
    fwrite(&cppdata.txt
    Not much but that is why I am asking for help!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,157
    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, 04: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, 12: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, 03:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21