[問題] 怎麼副函式中呼叫另一個副函式的位址or值
遇到的問題: (題意請描述清楚)
在第一個副函式中跑出來的pA
需要在第二個副函式中使用
不知道怎麼處理
希望得到的正確結果:
能在第二個副函式中得到第一個副函式的資料
開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux)
VS C++
有問題的code: (請善用置底文標色功能)
void Read(); //讀檔
void Read()
{
FILE *f2=fopen("aaa.dat","rb");
if(f2==NULL)
{
printf("開檔錯誤");
exit(1);
}
fseek( f2, 0, SEEK_END);
Long = ftell(f2)/sizeof(struct person);
printf("有幾筆資料:%d\n",Long);
person* pA = new person[Long];
fseek( f2, 0, SEEK_SET);
fread(pA,sizeof(struct person),Long,f2);
for(i=0;i<size;i++)
{
printf("%s \t",pA[i].name);
printf("%d \t\n",pA[i].year);
}
return &pA;
fclose(f2);
}
void Del(); //把比對到的資料刪除
void Del()
{
int CK;
FILE *f3=fopen("bbb.dat","wb");
for(i=0;i<size;i++) //要改Long
{
CK=strcmp(word,*pA[i].name);
printf("%d\n ",CK);
if(CK!=0)
{
printf("%s \t",pA[i].name);
printf("%d \t\n",pA[i].year);
fwrite(&pA[i],sizeof(struct person),1,f3);
}
}
fclose(f3);
}
補充說明:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.138.178.67
※ 編輯: dann1 來自: 140.138.178.67 (07/15 19:29)
→
07/15 19:32, , 1F
07/15 19:32, 1F
→
07/15 19:33, , 2F
07/15 19:33, 2F
→
07/15 19:36, , 3F
07/15 19:36, 3F
→
07/15 19:36, , 4F
07/15 19:36, 4F
→
07/15 19:37, , 5F
07/15 19:37, 5F
→
07/15 19:40, , 6F
07/15 19:40, 6F
→
07/15 19:41, , 7F
07/15 19:41, 7F
→
07/15 20:29, , 8F
07/15 20:29, 8F
→
07/15 20:29, , 9F
07/15 20:29, 9F
→
07/15 21:55, , 10F
07/15 21:55, 10F
→
07/16 01:10, , 11F
07/16 01:10, 11F