Thread: Storing Info From file into Array of structs

  1. #16
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    >> storm[g].name is my destination within my struct, but my source is an input file, so that makes me think my second argument is wrong.

    I can't see the declaration for 'name' so it's not clear, but assuming it's a char buffer with the same size as the struct member, you are doing it correctly (a 1000 times). Just be sure the variable 'name' isn't being used elsewhere in the program for some other purpose and you should be fine.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  2. #17
    Registered User
    Join Date
    Jun 2009
    thanks...i got it this part figured out using the ended up looking like this...

    while((i=fscanf(fp,"%10s %i %i %f", name, &lattitude, &longitude,&force))!=EOF){
    		storm[j].lattitude = lattitude ;
    		storm[j].longitude = longitude;
    		storm[j].force = force;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read a file (binary) into an array of structs
    By Separ in forum C Programming
    Replies: 3
    Last Post: 04-14-2009, 09:09 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

Tags for this Thread