1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: C\C++ help needed

  1. Oct 30, 2009 #1
    C\C++ help needed URGENT!!!

    I need help in C program
    I have to write a c/C++ progam to read a particular column in a .txt file.
    like
    23.40 90.46 -129.8 -0.3
    22.51 90.91 11.7 7.6
    22.51 91.35 11.3 -0.0
    22.06 90.46 29.1 7.8
    22.06 90.91 -12.6 3.8
    22.06 91.35 -49.2 -29.2
    22.06 91.80 -28.7 30.6
    In the abv file i have to read the third column and write in the seperate .txt file.
     
  2. jcsd
  3. Oct 30, 2009 #2
    Re: C\C++ help needed URGENT!!!

    One simple approach:
    1) Open the file and read each line to a string
    2) Use space delimiter to make an temporary array
    3) Make new file and write the third value
    ...
     
  4. Oct 30, 2009 #3

    Hepth

    User Avatar
    Gold Member

    Re: C\C++ help needed URGENT!!!

    its even easier if you know the number of columns. fscanf() works great for regular tabulated data.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook