Thread: how to get unknown no. of integers from a file

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

    how to get unknown no. of integers from a file

    Hii everyone.
    this is my first post and i am new to file handling in c as well.
    I have to draw a graph from two files each containing two columns e.g
    file A ........................... file B
    10 0.027 .......................10 0.022
    20 0.037 .......................20 0.030
    100 0.077 .....................100 0.065
    200 0.099 .....................200 0.080
    ...... .............................. ........

    As you can see the first column of both the files are same.
    I need to draw a graph between A.col1 and (A.col2/B.col2).
    Now, how do I take input from the files A and B which contain unknown number rows.
    Tried using feof() got segmentation fault error

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Tried using feof() got segmentation fault error
    And what does this tell us?

    Post your code, if you want an actual explanation of where you went wrong.
    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
    Registered User andrew89's Avatar
    Join Date
    Dec 2011
    Location
    Indiana, United States
    Posts
    80
    Debugging Segmentation Faults and Pointer Problems - Cprogramming.com

    There you go. Without the code we can't help much other than that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems Reading Line With Unknown Number of Integers
    By envec83 in forum C Programming
    Replies: 3
    Last Post: 09-27-2011, 11:20 AM
  2. Calculating Sum of Integers of Unknown Length
    By egnorth in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2010, 04:31 PM
  3. read unknown integers from text file
    By underlink in forum C Programming
    Replies: 2
    Last Post: 11-10-2009, 10:23 AM
  4. reading a file of unknown length
    By the bassinvader in forum C Programming
    Replies: 2
    Last Post: 07-12-2006, 03:06 PM
  5. Open an unknown lonely file in a dir?
    By hakan in forum C++ Programming
    Replies: 3
    Last Post: 02-07-2003, 03:23 PM