I am practicing my C++ programming just making an
Health Care related program, I cant seem to access
my data that is stored on a .txt file,
All I get is that f is not declared in this scope
Heres the code:
#include <iostream>
#include <stdlib.h>
#include "structr.h"
using namespace std;
void regsPat();
void database(FILE * f);
void saved(patient ab);
void menu(){
int opc;
system("cls");
cout<<" ----<-<-<>--<-INOMO MEDICARE->--<>-->->----"<<endl;
cout<<" 1. Register new Patient "<<endl;
cout<<" 2. Database "<<endl;
cout<<" 3. Statistics "<<endl;
cout<<" 4. Corporate "<<endl;
cout<<" 5. Help \n\n\n "<<endl;
cin>>opc;
switch (opc){
case 1:
regsPat();
break;
case 2:
database(f);//<------F WAS NOT DECLARED IN THIS SCOPE
break;
}
}
As you can see im trying to access a external function
its in another file heres the code that im using:
void database (FILE * f)
{int a;
system("cls");
//float suma=0, promedio;
//holaa.codigo=0;
f = fopen("saved.txt", "r");
if( f == NULL)
{
printf("\nData Does not Exist! \nPlease Create it");
return;
}
do
{
fread(&ab , sizeof(ab), 1, f);
if (feof(f))break;
printf("Name: %d\n",ab.name);
printf("Age: %s\n",ab.age);
printf("Body fat: %s\n",ab.bodFat);
printf("Height: %.1f\n",ab.height);
cout<<"=========================================================================="<<endl;
}while(!feof(f));
fread(&ab,sizeof(ab),1,f);
fclose(f);
fseek(f,ftell(f)-sizeof(ab),SEEK_END);
getch();
system("cls");
return;
}