Passing file between functions.
In the main, there is a switch case. Option 1 executes Function named Main_Linear_Reg()
Code:
#include "Pearson.h"
void Main_Linear_Reg();
void Main_Linear_Reg()
{
int n, i;
printf("Enter Number Of Pairs:\t");
scanf("%d", &n);
struct Pearson Per[n];
for(i=0; i<n; i++)
{
printf("Pair: %d\n",i+1);
InDetails(&Per[i]);
printf("\n");
}
system("cls");
for(i=0; i<n; i++)
{
printf("Pair: %d\n",i+1);
DiDetails(Per[i]);
printf("\n");
}
FILE *fptr;
fptr= fopen ("Data/t-test_Linear Regression.txt","w");
for(i=0; i<n; i++)
{
FileDetails(Per[i], &fptr);
}
The Functions used are from Pearson.h :
Code:
struct Pearson
{
float X;
float Y;
};
void InDetails(struct Pearson *P);
void DiDetails(struct Pearson P);
void FileDetails(struct Pearson P, FILE *OutFile);
void InDetails(struct Pearson *P)
{
printf("X:\t");
scanf("%f", &P->X);
printf("Y:\t");
scanf("%f", &P->Y);
}
void DiDetails(struct Pearson P)
{
printf("X:\t%3.3f, Y:\t%3.3f",P.X,P.Y);
}
void FileDetails(struct Pearson P, FILE *OutFile)
{
fprintf(OutFile,"X:\t%3.3f, Y:\t%3.3f",P.X,P.Y);
}
Code:
I get the following error:
5 main.c In file included from main.c
MainLin.h In function `Main_Linear_Reg':
62 [Warning] passing arg 2 of `FileDetails' from incompatible pointer type
What i want to do in this case is print all X and Y values of the struct to a file. If there is an alternative way, do let me know. Thanks.