ERROR IN PHONEBOOK

i cant figure out how to fix 2 errors..here it is

41- TransFS should have a prototype in function main()
102-call of nonfunction on function TransFS()




#include <iostream.h>
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>


struct Pb{

int Id,I;

char Fn[15],Pn[15];

}P[100];


struct FPb{

int Id,I;

char Fn[15],Pn[15];

}FP;

int TransFS(void);

void TransSF(void);

void Show(void),Add(void),Edit(void);

int NumEntry;


main()

{

char ans;


NumEntry=TranFS();

do{

clrscr();

cout<<"[A]dd [S]how [E]dit [Q]uit:";

ans=toupper(getch());


switch(ans){

case 'A': Add();

break;

case 'S': Show();

break;

case 'E': Edit();

break;

}

}while(ans!='Q');

remove("Phone.txt");

TransSF();

return 0;


}



//this code will transfer the file into srtuct

int TranFS()

{

FILE *fp;

int i,I;


fp = fopen("Phone.txt","r");

fread(&FP,sizeof(FP),I,fp);

while(feof(fp)==0){

i++;

P(i).Id=FP.Id;

strcpy(P[i].Fn,FP.Fn);

strcpy(P[i].Pn,FP.Pn);

fread(&FP,sizeof(FP),I,fp);

}



fclose(fp);

return i;

}


//this code will transfer the struct into file

void TransSF()

{

FILE *fp;

int i,I;


fp=fopen("Phone.txt","a");


for(i=I;i<=NumEntry;i++)


{

FP.Id=P[i].Id;

strcpy(FP.Fn,P[i].Fn);
strcpy(FP.Pn,P[i].Pn);
fwrite(&FP,sizeof(FP),I,fp);
}

fclose(fp);

}




void Show()
{

int i,I;

clrscr();

for(i=I;i<=NumEntry;i++){
cout<<"\n";
cout<<"\n Entry #:"<<i;
cout<<"\n ID :"<<P[i].Id;
cout<<"\n Fn :"<<P[i].Fn;
cout<<"\n Pn :"<<P[i].Pn;

getch();

}
}



void Add()
{
char ans;
do{
clrscr();
NumEntry++;
cout<<"Enter ID : ";
cin>>P[NumEntry].Id;
cout<<"Enter Fn :";
cin>>P[NumEntry].Fn;
cout<<"Enter Pn:";
cin>>P[NumEntry].Pn;
cout<<"Another Entry [Y/N]: ";
ans=getch();
}while(ans=='Y'||ans=='y');
}




void Edit()
{
int i,id,I;
clrscr();
cout <<"Edit Entry \n";
cout<<"Enter ID number:";
cin>>id;
for (i=I;i<=NumEntry;i++){
if(id==P[i].Id){
cout<<"Enter New ID:";
cin>>P[i].Id;
cout<<"Enter New Fn:";
cin>>P[i].Fn;
cout<<"Enter new Pn:";
cin>>P[i].Pn;
i=NumEntry;

}
}


}






First of all in main() u call "TranFS", ur function is "TransFS". In function TransFS u have something like "P(i).Id=FP.Id;"....in stead of P[i].....
U also wrote
"int TranFS()

{...." in stead of TransFS.....
Have fun!
Topic archived. No new replies allowed.