fin undeclared identifier, but is declared

closed account (SiEURXSz)
Program is not finished as I can't get passed read_data

Error: "error C2065: 'fin' : undeclared identifier
error C2228: left of '.open' must have class/struct/union type is ''unknown-type''

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
#include "stdafx.h"
#include <iostream> // for streams
#include <iomanip>  // for setw()
#include <fstream>  // for files
#include <cstdlib>  // for exit

using namespace std;

void read_data(int A[], int size)
{
	char name[16];

	cout << "Enter a file name of 15 characters or less";
	cin >> name;
	
	fin.open(name, ios::in); 
     
	for (int i=0; i<size; i++)
	{
	  fin << A[i] << " ";
	}
   fin.close(); 

}
void print_data(int A[], int size)
{

}
void bubble_sort(int A[], int size)
{
	int temp;
		for (int i=0; i<size-1; i++)
			for (int j=0; j<size-1; j++)
				if (A[j]>A[j+1])
				{ 
					temp = A[j];
					A[j]=A[j+1];
					A[j+1]=temp;
				}
}  
int main()
{
	const int size=100;
	int A[size]={0};
	void read_data(int A[], int size);
	void bubble_sort(int A[], int size);
	void print_data(int A[], int size);

	return 0;
}
I don't see where fin is declared. You need to declare it first.
closed account (Dy7SLyTq)
are you actually going to use those functions or just declare them c style?
Topic archived. No new replies allowed.