GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


Helping noms by Zera
1
 
#include<iostream>
#include<fstream>
#include<iomanip>
#include<conio.h>
#include <stdlib.h>

using std::ifstream;
using std::cout;
using std::endl;
using std::setw;
using std::setprecision;
using std::setiosflags;
using std::ios;


int main() {
    char string[256];
    int Length;

    ifstream file;
    
    file.open("Phones.txt");
    if(!file) {
        cout << "Error: File could not be open.\n" << endl;
        exit(1);
    }

    while(!file.eof()) {
//        file >> string;
        file.read(string, 256); // NEW
        Length = strlen(string);
        if (Length > 256) Length = 256; // NEW
        for(int i = 0; i < Length; i++) { // NEW
//        for(int i = 0; i < 256; i++) {
            cout << string[i];
        }
    }

    cout << " " << endl;

    cout << "Press any key to quit..." << endl;
    getch();

    return 0;
}