file i/o

This is a discussion on file i/o within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi im makeing a program and what i want to do is have usernames just to keep prefrences straight so ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    16

    Exclamation file i/o

    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
    • 0927
    • a.k.a 0 9 two 7

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    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. */

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. 2 questions surrounding an I/O file
    By Guti14 in forum C Programming
    Replies: 2
    Last Post: 08-31-2004, 12:21 AM
  4. File I/O problems!!! Help!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 05-17-2002, 09:09 PM
  5. advice on file i/o
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-29-2001, 05:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21