1. Not finding help here? Sign up for a free 30min 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!

Help Scanning File Data In C!

  1. Jan 24, 2008 #1
    1. The problem statement, all variables and given/known data
    Ok, here is the other question thats giving me a headache. There is a file which holds 5 data items per line and a minimum of 1 line. The data is always in the order float float integer float string and each element is separated by a space. So we need to ask the user for a file name and then we need to output the data to the user in a user friendly way. It lets me compile but after it prints out everything i get a stack smashing detected error which I have no clue as to its meaning. We just learned pointers and how to open and read files and stuff and I am very confused. We were never taught fgets in class so I tried to teach myself on the net so I am a little confused. It lets me put the whole contents of the file i'm reading into a 20 character array i made called weatherFile?

    I also somehow need to print off each individual data item with several spaces in between instead of single spaces like how the original file is to make it more user friendly and i'm not sure how to do that with the way I have it written now. So if someone can take a look at the program I have so far and help me, it would be very greatly appreciated. Thanks for your time! :)

    Program: http://rafb.net/p/FaBfWS88.html
    Last edited: Jan 24, 2008
  2. jcsd
  3. Jan 27, 2008 #2


    User Avatar
    Gold Member

    Your paste on rafb.net has expired. Please repost.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Help Scanning File Data In C!