الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الاضافه في في اول الملف

مغلق
بدأه فلسفة في 15 ديسمبر 2003 · 2 رد · 631 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته واجهت خطا مافهمت وش المقصود منه ولاعرفت كيف اتعامل معه

الي انا ابيه اضيف عنصر في اول الملف هذا الغلط الي من الكوبايلر

--------------------Configuration: Cpp1 - Win32 Debug--------------------

Linking...

Cpp1.obj : error LNK2001: unresolved external symbol "void __cdecl insert_first(struct _iobuf *)" (?insert_first@@YAXPAU_iobuf@@@Z)

Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals

Error executing link.exe.

Cpp1.exe - 2 error(s), 0 warning(s)

--------

وهذا البرنامج كامل؟؟؟؟؟

#include<stdio.h>
/*********** Data ***********/
typedef struct {
	int id;
	float gpa;
}data;
/*********** The functions ***********/
void read(data*);
void print(FILE*);
void insert_last(FILE*);
void insert_first(FILE*);
void insert_After_Target(FILE*,int);
void delet_first(FILE*);
int search(FILE*,int);
int size(FILE*);
void copy(FILE*,FILE*);
void menu();
/*********** Main ***********/
int main(){
	data R;
	FILE *f;
	int choice;
	int i,t,n;
	if((f=fopen("f.dat","w"))==NULL)
  printf("sorry i can not open the file\n");
	else{
	for(i=0;i<3;i++){
  read(&R);
  fprintf(f,"%d %.2f ",R.id,R.gpa);
	}
	fclose(f);
	menu();
	scanf("%d",&choice);
	while(choice!=6){
  switch(choice){
  case 1:
 	 insert_first(f);
 	 menu();
 	 break;
  case 2:
 	 insert_last(f);
 	 menu();
 	 break;
  case 3:
 	 printf("Enter the Taget: ");
 	 scanf("%d",&t);
 	 n=search(f,t);
 	 printf("n=%d\n",n);
 	 if(n==1)
 	 insert_After_Target(f,t);
 	 else
    printf("Target not found\n");
 	 menu();
 	 break;
  case 4:
 	 print(f);
 	 menu();
 	 break;
  case 5:
 	 delet_first(f);
 	 menu();
  default :
 	 printf("Error choice try agan\n");
   menu();
 	 break;
  }
  scanf("%d",&choice);
	} 

	}
	return 0;
}

/*********** Menu ***********/
void menu(){
	printf("+------------------------------------------------------+");
	printf("\n|                | The Main Menu |                     |");
	printf("\n+------------------------------------------------------+");
	printf("\n| 1- Inserts a new data in the first.                  |");
	printf("\n| 2- Inserts a new data in the last.                   |");
	printf("\n| 3- Inserts After Target.                             |");
	printf("\n| 4- Print The File.                                   |");	
	printf("\n| 5- Delet First.                                      |");
	printf("\n| 6- End.                                              |");	
	printf("\n+------------------------------------------------------+");
	printf("\nEnter your choice :");
}
/*********** Read ***********/
void read(data *R){
	printf("Enter the id :");
	scanf("%d",&R->id);
	printf("\n");
	printf("Enter the gpa :");
	scanf("%f",&R->gpa);
	printf("\n");
}
/*********** Print ***********/
void print(FILE *f){
	data R;
  if((f=fopen("f.dat","r"))==NULL)
  printf("sorry i can not open the file\n");
	else{
  fscanf(f,"%d %f",&R.id,&R.gpa);
	while(!feof(f)){  
  printf("The id is: %d the gpa is: %.2f\n",R.id,R.gpa);
  fscanf(f,"%d %f",&R.id,&R.gpa);
	}
	fclose(f);
}
}
/*********** Insert Last ***********/
void insert_last(FILE *f){
	data R;
	if((f=fopen("f.dat","a"))==NULL)
  printf("Sorry can not open the file\n");
	else{
  read(&R);
  fprintf(f,"%d %f ",R.id,R.gpa);
  fclose(f);
	}
}
/*********** Insert After Target ***********/
void insert_After_Target(FILE *f,int t){
	FILE *f2;
	data R;
	data Z;
	f=fopen("f.dat","r");
	f2=fopen("f2.dat","w");
	while(!feof(f)){
  fscanf(f,"%d %f ",&R.id,&R.gpa);
  fprintf(f2,"%d %f ",R.id,R.gpa);
  if(R.id==t){
 	 read(&Z);
 	 fprintf(f2,"%d %f ",Z.id,Z.gpa);
  }
	}
	fclose(f);
	fclose(f2);
	f=fopen("f.dat","w");
	f2=fopen("f2.dat","r");
	while(!feof(f2)){
  fscanf(f2,"%d %f ",&R.id,&R.gpa);
  fprintf(f,"%d %f ",R.id,R.gpa);
	}
	fclose(f);
	fclose(f2);
}
/*********** Search ***********/
int search(FILE *f,int t){
	data R;
	int m=0;
	f=fopen("f.dat","r");

	while(!feof(f)){
 	 fscanf(f,"%d %f ",&R.id,&R.gpa);
  if(R.id==t){
    m=1;
    fclose(f);
    return m;
  }

	}
	fclose(f);
	return m=0;

}
/*********** Size ***********/
int size(FILE*f){
	int c=0;
	data R;
	f=fopen("f.dat","r");
	while(!feof(f)){
  fscanf(f,"%d %f ",&R.id,&R.gpa);
  c++;
	}
	fclose(f);
	return c;
}
/*********** Delet First ***********/
void delet_first(FILE *f){
	FILE *f2;
	data R;
	f=fopen("f.dat","r");
	f2=fopen("f2.dat","w");
	fscanf(f,"%d %f ",&R.id,&R.gpa);
	while(!feof(f)){
  fscanf(f,"%d %f ",&R.id,&R.gpa);
  fprintf(f2,"%d %f ",R.id,R.gpa);
	}
	fclose(f);
	fclose(f2);
	f=fopen("f.dat","w");
	f2=fopen("f2.dat","r");
	while(!feof(f2)){
  fscanf(f2,"%d %f ",&R.id,&R.gpa);
  fprintf(f,"%d %f ",R.id,R.gpa);
	}
	fclose(f);
	fclose(f2);
}
/*********** Copy ***********/
void copy(FILE *f,FILE *f2){
	data R;
	while(!feof(f2)){
  fscanf(f2,"%d %f ",&R.id,&R.gpa);
  fprintf(f,"%d %f ",R.id,R.gpa);
	}
}
/*********** Insert First ***********/
void insert_fist(FILE *f){
	FILE *f2;
	data R;
	f=fopen("f.dat","r");
	f2=fopen("f2.dat","w");
	read(&R);
	fprintf(f2,"%d %f ",R.id,R.gpa);
	while(!feof(f)){
  fscanf(f,"%d %f ",&R.id,&R.gpa);
  fprintf(f2,"%d %f ",R.id,R.gpa);
	}
	fclose(f);
	fclose(f2);
	f=fopen("f.dat","w");
	f2=fopen("f2.dat","r");
	while(!feof(f2)){
  fscanf(f2,"%d %f ",&R.id,&R.gpa);
  fprintf(f,"%d %f ",R.id,R.gpa);  
	}
	fclose(f);
	fclose(f2);
}

ان شاءلله الاقي الاجابه عندكم

#2

السلام عليكم,

الخطء بسيط جدا وأضن أنك كتبت في الأول الدالة insert_first في التعريف ولكن عند كتابة الدالة كتبت inset_fist كتبت fist عوض first .

وعلى العموم عندما تكون عندنا هده الأنواع من الأغلاط في اللنكر فإن الدالة تكون غير موجودة.

إاى اللقاء.

#3

اول شي يعطيك الف عافيه0000وانت تعرف والله سهر على هالبرامج حتى بدينا نحلم فيها وفي الاخر تكون هذي اغلاطنا000 الحمدالله على كل حال

:)

مشكور مرة ثانيه

هذا الموضوع مغلق.

مواضيع مشابهة