PDA

View Full Version : file i/o



0927
11-10-2001, 09:36 AM
Hi im makeing a program and what i want to do is have usernames just to keep prefrences straight so i want it to open user.txt and match the user input and find the one in there then make a variable like 34 to denote thats its there preferences how would i do this if im not giveing enough information tell me and ill put more in

qwertiop
11-10-2001, 02:59 PM
i'm not exactly clear on what you mean, but to open a data file include fstream.h and try this:

whatevertype data;
ifstream infile(users.txt);

infile>>data;


/*this will take the first word or number in the file and save in into data. if you want to get the whole file, your will have to declare an array and make a loop. */