Reading a flie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
Stephen Ingram
CS 115 Sec 401
D. Cichon
10/25/2008
s.ingram@uky.edu
This program decides whether a .txt file passes a certain test based on its contents. 
**/

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
void invalid_Password(int pass_Length);
using namespace std;

int main()
{
	string file;
	string password;
	string name;
	int num1;
	int num2;
	ifstream InFile;
	ofstream OutFile;


	cout << "Secure Password Checker." << endl;
	cout << "Please enter the name of the file you want checked --> ";
	cin >> file;

	//Open the file
	InFile.open(file.c_str());

	if(InFile.is_open() == false)
	{
		cout << "Sorry, there must be a mistake, there is no such file!" << endl;
		return 1;
	}

	//reading file for strings and such to start out the test
	getline(InFile, name);
	getline(InFile, password);
	InFile >> num1;
	InFile >> num2;

	

	//close file
	InFile.close();
	
	int pass_Length = password.length();
	invalid_password(int pass_Length);

	return 0;
}

void invalid_Password(int pass_Length)
{
	if(password.length() < 6)
	{
		cout << "The file myfile.txt is invalid." << endl;
	}
}


It's telling me that password in password.length() has not been identified. What's wrong with it?
You have made an error in Line 60 - in the invalid_Password function.
This functions has no local string variable called password, so your
statement if(password.length() < 6) is incorrect.

You meant to check the value of pass_Length.
Topic archived. No new replies allowed.