Anyone have a better method in reading files?

This is a discussion on Anyone have a better method in reading files? within the C++ Programming forums, part of the General Programming Boards category; #include <iostream> #include <fstream.h> #include <conio.c> #define file "C:\My Documents\file.txt" int main() { int size=sizeof(file); char *cream; cream=new char[size]; int ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    156

    Anyone have a better method in reading files?

    #include <iostream>
    #include <fstream.h>
    #include <conio.c>
    #define file "C:\\My Documents\\file.txt"

    int main()
    {
    int size=sizeof(file);
    char *cream;
    cream=new char[size];
    int i=0;

    ofstream x(file);
    x << "Who Let The Dogs Out?!" << endl;
    x << "You Did?!" << endl;
    x << "Didn't You?!" << endl;
    x.close();

    ifstream y(file);
    for (i=0;i<=size;i++) {
    y >> cream; cout << cream << " ";
    y.clear(); }
    y.close();

    delete [] cream;

    getch();
    return 0;
    }
    Compiler: MingW(IDE: Bloodshed Dev-C++ 4.01)
    Web Site: Zoo Crew
    Forums: Zoo Boards
    E-mail: goldenbunny84@hotmail.com

    "Do you wanna go to jail or do you wanna go home?!?!" - Alonzo(Training Day)

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    You could write a class to handle all your file input and output...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading files
    By hiya in forum C++ Programming
    Replies: 7
    Last Post: 05-21-2005, 12:40 PM
  2. Reading data from consecutively named files
    By a1pro in forum C Programming
    Replies: 10
    Last Post: 04-15-2005, 02:48 AM
  3. A little help reading from files...
    By Invincible in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2002, 10:43 AM
  4. problem reading files in C
    By angelfly in forum C Programming
    Replies: 9
    Last Post: 10-10-2001, 12:58 PM
  5. Need Advice in reading files
    By jon in forum C Programming
    Replies: 4
    Last Post: 10-07-2001, 08:27 AM

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