Thread: struct,pointer and file

  1. #1

    struct,pointer and file


    struct bike
    char manuf[25];
    int id;
    bool rcode;
    char customer[25];
    int size;
    float rentcoast;
    bike *manufP;
    bike *idP;
    int main( )
    bike *temp;
    int code;
    char ch[20];
    ifstream filestr;"lib/lab1.dat");

    I want to write a function that will allocate storage for a new bike struct (a new node), read the data for the bike data members from a file named lib/lab1.dat, and return a pointer to the new node.
    how can I write this function?


  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    You can allocate memory with the 'new' keyword and the read the file with filestr.get()/filestr.getline() etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM