Readin' Files

Myself (and others) are wondering how to write prgs that read and manipulate data in files w/ structures and arrays.

For example, I know if you're using ints and floats u'd use sum'n like this:

struct fstruct
{
int a;
float b;
float c;
}

cout << "Enter a file name: ";
getline(cin, file_name);
file.open(file_name.c_str());
while((inByte = myFile.get()) !=EOF)
myFile.clear();
myFile.close();

this doesn't compile, but I know it looks kinda like that. can sum1 help me w/ this?
I have always used the standard C approach to do this. You can use the fwrite() / fread() functions.

http://www.cppreference.com/stdio/fwrite.html
http://www.cppreference.com/stdio/fread.html

Hope this helps.
Z.
Topic archived. No new replies allowed.