CIS 2 Programming Assignment

Hey guys, i am having trouble finishing my program. Here's the program. I am getting an error saying my 'fin' is not declared. I also need to include a loop to allow the user to enter the file name twice before exiting if the file does not exist that they entered. Here is my program that i have typed up so far. If anyone has any answers that would be great. Thanks!

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

void showContent(fstream &);

int main(void)
string fileName;
char line[100];
fstream fin;
fstream dataFile;

cout << "Please enter the Filename: " << endl;
cin >> fileName;, ios::in);


cout << "Error Opening File! Re-enter File Name: " << endl;
cin >> fileName;


void showContent(fstream &file)
int counter = 0;
char getch();

if (counter > 21)
counter = 0;

fin.getline(line, 101, '\n');
cout << line << endl;
fin is only available in main. Since showContent has a parameter file you should use it.
Also forget about eof(). It doesn't work like you expect. Google will tell you why.
Registered users can post here. Sign in or register to post.