Thread: help with reading data file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>printf("%s - %s - %s - %s",movies[k].title,movies[k].rating,movies[k].date,movies[k].length);
    This doesn't output any newline characters, you need a \n at the end of each line (I assume). Same for the other printf() statement too.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    44
    Quote Originally Posted by Hammer
    >>printf("%s - %s - %s - %s",movies[k].title,movies[k].rating,movies[k].date,movies[k].length);
    This doesn't output any newline characters, you need a \n at the end of each line (I assume). Same for the other printf() statement too.
    if i put a \n after each printf then some will have double space and some will have one space

  3. #3
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    You have a '\n' in the beggining of evry movie title except for the first move in the file.

    *edited

    try
    Code:
     for (i=0;i<SIZE;i++)
        {
              fscanf(in_file, "\n%35[^,],%10[^,],%10[^,],%3[^\n]",movies[i].title, movies[i].rating,movies[i].date,&movies[i].length);              
     
         }
    Last edited by loko; 10-02-2005 at 05:55 PM.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    44
    Quote Originally Posted by loko
    You have a '\n' in the beggining of evry movie title except for the first move in the file.

    *edited

    try
    Code:
     for (i=0;i<SIZE;i++)
        {
              fscanf(in_file, "\n%35[^,],%10[^,],%10[^,],%3[^\n]",movies[i].title, movies[i].rating,movies[i].date,&movies[i].length);              
     
         }
    thx works like a charm now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. reading data from a file
    By brianptodd in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2003, 06:50 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM