0
using namespace std;
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>

int main()
{
	ifstream InStream;
	string InFile;
	string InToken;

	cout << "Please enter the filename: " << endl;
	cin >> InFile;

	InStream.open( InFile.c_str(), ios::in );

	if (InStream.fail())
	{
		cerr << "Unable to open '" << InFile << "' for input." << endl;
	}

	const int MAX = 81;
	char A[MAX];

	cin.getline( A, MAX );
	cout << A << endl;
}

There's my code -- what I'm trying to do is get the first line of files (assumed to be no more than 80 characters) stored into the char array A, and then display that array. This doesn't seem to be working for me, any tips?

Edited by Metsuba: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Metsuba
0

Nevermind -- got it figured out :) Thanks anyways though

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.