fputs with carriage return?

This is a discussion on fputs with carriage return? within the C Programming forums, part of the General Programming Boards category; I am using the fputs function to create a list, but all of the items in the list are on ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    7

    fputs with carriage return?

    I am using the fputs function to create a list, but all of the items in the list are on the same line. Any idea how to get the fputs function to put in a carriage return?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Add a newline to the end of whatever string you are printing. Or just use puts, or fprintf or some other random function.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    7
    I have to add the item through a function and I forgot to say that the list it being written to a text file.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So strcat on a newline, or use fprintf instead.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,491
    There's also fputc, as in fputc('\n', fp).

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by goat37 View Post
    I am using the fputs function to create a list, but all of the items in the list are on the same line. Any idea how to get the fputs function to put in a carriage return?
    Or... you can call fputs("\n",file); wherever you need a newline in your file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. automatic carriage return?
    By A34Chris in forum C Programming
    Replies: 5
    Last Post: 09-17-2007, 08:53 PM
  2. how to accept a carriage return ?
    By mramazing in forum C Programming
    Replies: 5
    Last Post: 01-09-2007, 03:24 PM
  3. carriage return when tokenizing
    By wjday in forum C Programming
    Replies: 6
    Last Post: 11-17-2001, 06:10 AM
  4. _getch() and doing a carriage return
    By Leeman_s in forum C++ Programming
    Replies: 7
    Last Post: 10-01-2001, 02:19 PM
  5. Carriage Return Line Feeds
    By dattanij in forum C Programming
    Replies: 1
    Last Post: 09-07-2001, 04:41 AM

Tags for this Thread


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