コード例 #1
0
ファイル: trap.c プロジェクト: juanfra684/DragonFlyBSD
void
exitshell_savedstatus(void)
{
    struct jmploc loc1, loc2;
    char *p;
    volatile int sig = 0;
    sigset_t sigs;

    if (!exiting) {
        if (in_dotrap && last_trapsig) {
            sig = last_trapsig;
            exiting_exitstatus = sig + 128;
        } else
            exiting_exitstatus = oexitstatus;
    }
    exitstatus = oexitstatus = exiting_exitstatus;
    if (setjmp(loc1.loc)) {
        goto l1;
    }
    if (setjmp(loc2.loc)) {
        goto l2;
    }
    handler = &loc1;
    if ((p = trap[0]) != NULL && *p != '\0') {
        trap[0] = NULL;
        evalstring(p, 0);
    }
l1:
    handler = &loc2;			/* probably unnecessary */
    flushall();
#if JOBS
    setjobctl(0);
#endif
l2:
    if (sig != 0 && sig != SIGSTOP && sig != SIGTSTP && sig != SIGTTIN &&
            sig != SIGTTOU) {
        signal(sig, SIG_DFL);
        sigemptyset(&sigs);
        sigaddset(&sigs, sig);
        sigprocmask(SIG_UNBLOCK, &sigs, NULL);
        kill(getpid(), sig);
        /* If the default action is to ignore, fall back to _exit(). */
    }
    _exit(exiting_exitstatus);
}
コード例 #2
0
ファイル: q1a.c プロジェクト: C12331591/College-Work
main()
{
	int *ptr;
	int no_els, no_bytes, i;
	
	printf ("Enter the number of elements.");
	scanf ("%d", &no_els);
	
	/*Calculating the number of bytes
	*/
	
	no_bytes=no_els;//sizeof(int) removed
	
	/*Allocating the memory
	*/
	
	ptr=(int*)malloc(no_bytes);
	
	if (ptr==NULL)
	{
		printf ("Cannot allocate memory.\n");
	}
	
	else
	{
		for (i=0;i<no_els;i++)
		{
			printf ("\nEnter element %d.\n", i);
			scanf ("%d", &*(ptr+i));
		}
	
		/*Display the number entered into the memory block
		*/
		
		for (i=0;i<no_els;i++)
		{
			printf ("\nElement %d is %d.\n", i, *(ptr+i));
		}
		
		free(ptr);
		
		flushall();
		getchar();
	}//end if
}//end main
コード例 #3
0
ファイル: error.c プロジェクト: RajasekharBhumi/L4Re
/*
 * Exverror is called to raise the error exception.  If the second argument
 * is not NULL then error prints an error message using printf style
 * formatting.  It then raises the error exception.
 */
static void
exverror(int cond, const char *msg, va_list ap)
{
#ifdef DEBUG
	if (msg) {
		TRACE(("exverror(%d, \"", cond));
		TRACEV((msg, ap));
		TRACE(("\") pid=%d\n", getpid()));
	} else
		TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
	if (msg)
#endif
		exvwarning(-1, msg, ap);

	flushall();
	exraise(cond);
	/* NOTREACHED */
}
コード例 #4
0
ファイル: q1.c プロジェクト: kieranhogan13/C
main()
{
    int x;
    int result;
 
    printf("Input a number to see if its odd or even:\n");
    scanf("%d",&x);
    
    /*Call function*/
    result = odd_even(x);
    if(result==1)
        printf("Even");
    else
        printf("Odd");
    
    flushall();
    getchar();
}    
コード例 #5
0
ファイル: STDAXE3.CPP プロジェクト: cgfloare/consteq
void axele(double *d)
{
int c;
double zero[3];
void limite(double *d,double *e);
void drawaxe(double *f);
	puts("Did you want axes ? (y/n)");
	flushall();
	c=bioskey(0);
	if(c==5465||c==5497)
	{
		limite(d,zero);
		drawaxe(zero);
	}
	else
		cleardevice();
	return;
}
コード例 #6
0
ファイル: q1.c プロジェクト: C12331591/College-Work
main()
{
	float side, sq_area, rad, cir_area;
	
	printf ("Please enter the length of a side of the square.\n");
	scanf ("%f", &side);
	printf ("Please enter the radius of the circle.\n");
	scanf ("%f", &rad);
	
	square(&side, &sq_area);
	circle(&rad, &cir_area);
	
	printf ("\nThe area of the square is %f.", sq_area);
	printf ("\nThe area of the circle is %f.", cir_area);
	
	flushall();
	getchar();
}//end main()
コード例 #7
0
//------------------------------Timer Thread--------------------------------------
void* timer_thread(void*notused)
{
	int time_count;
	int rcvid_timer;
	while(1)
	{	
		rcvid_timer = MsgReceivePulse(timerChid, &timerPulse, sizeof(timerPulse), NULL);
		if (rcvid_timer==-1)
		{
			printf("Error in timer pulse!\n");
			flushall();
		}
		else
		{writeMsg(COMMEND_RESET);}
		delay(50);
			
	}
}
コード例 #8
0
angleline (){
	char selector;
	puts ("what type of line do you have?\nis it (o)pposite or (a)djacent to the angle that you have or is it the (h)ypotenuse?\nor if you wish to go to the previous menu please enter \"p\"");
	scanf ("%c", &selector);
	flushall();
	selector = toupper (selector);
	if (selector == 'A'){
		anglelineadjacent();
	} else if (selector == 'O'){
		anglelineopposite();
	} else if (selector == 'H'){
		anglelinehypotenuse();
	} else if (selector == 'P'){
		trigonometry();
	} else {
		angleline();
	}
}
コード例 #9
0
ファイル: TREE.CPP プロジェクト: ganeshpaib/CollegePrograms
tree_ptr insert(char item,tree_ptr root)
{
	tree_ptr temp,prev,cur;
	int i;
	char direction[10];
	temp=(tree_ptr)malloc(sizeof(struct node));
	temp->data=item;
	temp->left_child=temp->right_child=NULL;
	if(root==NULL)
	{
		root=temp;
		return root;
	}
	printf("\nenter the direction where the node have tobe inserted...");
	flushall();
	scanf("%s",direction);
	prev=NULL;
	cur=root;
	dir[ctr]=strlen(direction);
	strcpy(path[ctr],direction);

	for(i=0;i<strlen(direction) && cur!=NULL ;i++)
	{
		prev=cur;
		val[ctr]=item;
		if(direction[i]=='l')
			cur=cur->left_child;
		else
			cur=cur->right_child;

	}
	if(cur!=NULL || i!=strlen(direction) )
	{
	  printf("\ninsertion not possible");
	  free(temp);
	  return(root);
	}
	if(direction[i-1]=='l')
		prev->left_child=temp;
	 else
		prev->right_child=temp;
	 ctr++;
	 return root;
}
コード例 #10
0
ファイル: LOGIN.C プロジェクト: skbly7/social-network-project
void load_users(void)
{
int count,nofilen,dbfilecount=0;
char username[10],password[10];
FILE *f1;
head=NULL;
end=NULL;
     flushall();
     f1 = fopen ("users.txt","r");
     if (f1==NULL)
     {
	fprintf(stderr,"There was an error reading your database file!");
	getch();
     }
     else
     {
		count=0;
		head=NULL;
		end=NULL;

		while (!feof(f1))
		{
		temp=(member *)malloc(sizeof(member));
		fscanf(f1,"%s\t%s\t%c\n",temp->username,temp->password,temp->sex);
		temp->next=NULL;

		if(head==NULL)
		{
		head=temp;
		end=temp;
		}
		else
		{
		end->next=temp;
		end=temp;
		}
		count++;
	  }
	  printf("Database successfully loaded! Records count : %d",count);
	  total_entry = count;
	  getch();
	  }
     fclose(f1);
}
コード例 #11
0
ファイル: LOGIN.C プロジェクト: skbly7/social-network-project
void loaddatabase(void)
{
int count,nofilen,dbfilecount=0;
char finphone[80];
char finroom[80];
char dbload[20];
int error_junk;

long int l_finphone;
int i_finroom;

FILE *f1;
     printf("Enter the filename of the database: ");
	 printf("Example: c:\\hostel.txt or c:\\flat.txt");
     gets(dbload);
     flushall();
     f1 = fopen (dbload,"r");
     if (f1==NULL)
     {
	fprintf(stderr,"There was an error reading your database file!");
	strcpy(dbload, "DATABASE ERROR...");
	getch();
     }
     else
     {

		count=0;
		while (!feof(f1))
	    {
		fscanf(f1,"%s\t%s\n",&finroom,&finphone);
	     i_finroom = atoi(finroom);
	     l_finphone = atol(finphone);
		room[count] = i_finroom;
		phone[count] = l_finphone;
		count++;
	  }
	  printf("Database %s, was successfully loaded! Records no : %d",dbload,count);
	  getch();
	  total_entry = count;

	  }

     fclose(f1);
}
コード例 #12
0
ファイル: q3.c プロジェクト: C12331591/College-Work
main()
{
	int i;
	int input[NUMBERS];
	int ans;
	
	for (i=0;i<NUMBERS;i++)
	{
		printf ("Please enter element %d.\n", i);
		scanf ("%d", &input[i]);
	}//end for
	
	ans=highest(input);
	
	printf ("\nThe highest is %d.", ans);
	
	flushall();
	getchar();
}//end main()
コード例 #13
0
ファイル: main1.c プロジェクト: priyaranjan-behera/OSPrograms
int main(int argc, char *argv[])
{
  Pipe p;
  char host[25];
  gethostname(host, 25);
  char* home=malloc(100);
  int fdin;
  backupIO();

  home = strdup(getenv("HOME"));
  strcat(home, "/.ushrc");

  if((fdin=open(home, O_RDONLY))==-1)
    perror("OPEN USHRC"); 
  else
  {
    dup2(fdin, 0);
    close(fdin);
    printf("%s%% ", host);
    fflush(stdout);
    p = parse();
    currPipe = 0;
    prPipe(p);
    //freePipe(p);
  }

  
  


  while ( 1 ) {

    restoreIO();
    flushall();
    printf("%s%% ", host);
    fflush(stdout);
    p = parse();
    currPipe = 0;
    prPipe(p);
    //freePipe(p);

  }
}
コード例 #14
0
ファイル: tictactoe.cpp プロジェクト: MileWalkers/USC
void main(){
	char nice='y';
	while(nice == 'y'){
		char winner = 'N';
		bool turn=true, validty;
		int move, counter=1, i, m=49;
		char board[9];
		for (i=0; i<9; i++){
			board[i] = m;
			m++;
		}
		PrintBoard(board);
		while (winner == 'N'){
			printf("Where do you want to go? Pick an available number: ");
			scanf("%d", &move);
			validty = IsValidMove(board, move-1);
			while (validty==false || board[move-1]=='X' || board[move-1]=='O'){
				printf("INVALID MOVE. PICK AGAIN.\n");
				printf("Where do you want to go? Pick an available number: ");
				scanf("%d", &move);
				validty = IsValidMove(board, move-1);
			}
			if (turn)
				board[move-1] = 'X';
			else
				board[move-1] = 'O';
			PrintBoard(board);
			winner = WinnerIfAny(board);
			if (counter==9 && winner=='N')
				winner = 'S';
			turn = !turn;
			counter++;
		}
		if(winner != 'S')
			printf("CONGRATULATIONS PLAYER %c!!! YOU WON!!!\n", winner);
		else
			printf("STAKENATE!!!\n");
		printf("Would you like to play another game?(y/n):");
		flushall();
		scanf("%c", &nice);
	}
}
コード例 #15
0
ファイル: q3.c プロジェクト: kieranhogan13/C
main()
{
    printf("Average from array of 5\n\n");
    int numbers[5];
    int size = 5;
	int average;
    int i;
    for(i=0;i<size;i++)
    {
        printf("Enter element: ");
        scanf("%d", &numbers[i]);
        printf("\n");
    }
        
	/*Call the function sum_array()*/
	average = my_array(numbers);
	printf("The average is %d", average);
    flushall();
    getchar();
}//end main
コード例 #16
0
trigonometry (){
	char selectora;
	char selectorb;
	puts ("do you have lines and angles, just angles or just lines? \nIf you have both angles and lines please enter \"al\"\nIf you only have lines please enter \"ll\"\nOr for the main menu please enter \"m\"");
	scanf ("%c%c", &selectora, &selectorb);
	flushall ();
	selectora = toupper (selectora);
	selectorb = toupper (selectorb);
	
	if (selectora == 'L' && selectorb == 'L'){
		lineline();
	}else if (selectora == 'A' && selectorb == 'L'){
		angleline();
	}else if (selectora == 'L' && selectorb == 'A'){
		angleline();
	}else if (selectora == 'M' || selectorb == 'M'){
		main();
	}else {
		trigonometry();
	}
}
コード例 #17
0
ファイル: ui.cpp プロジェクト: panoti/THKTLT-DACK2013
int createBox(STR text, int style, bool cont)
{
	if (!cont) {
		system("cls");
		showHeader();
	}
	while (1)
	{
		printf("%s ", text);
		if (style == 1)
			printf("[o] > ");
		else if (style == 2)
			printf("[y/n] > ");

		flushall();
		char bx = getchar();
		if (bx == 'o' && style == 1) return BX_OK;
		else if (bx == 'y' && style == 2) return BX_YES;
		else if (bx == 'n' && style == 2) return BX_NO;
	}
}
コード例 #18
0
void Pathfinder::inputPlace()
{
	string name;
	int id;
	string longitude;
	string lattitude;
	int elevation;
	flushall();
	cout << "Enter a new place!\nName:";
	getline(cin, name);
	cout << "Longitude";
	getline(cin, longitude);
	cout << "Lattitude:";
	getline(cin, lattitude);
	cout << "Elevation (feet):";
	cin >> elevation;
	
	place *p = new place(name, lattitude, longitude, elevation, getNextId());

	places.push_back(p);
}
コード例 #19
0
ファイル: SUBSTR.C プロジェクト: ganeshpaib/CollegePrograms
void main()
{
	char str[20],sub_str[20],rep[20];
	int len,sub_len,i,pos;
	clrscr();
	printf("\n\tEnter the string  :  ");
	scanf("%[^\n]",str);
	printf("\n\tEnter the starting position of the substring	: ");
	scanf("%d",&pos);
	printf("\n\tEnter the length of the string	:  ");
	scanf("%d",&sub_len);
	str_sub(str,sub_str,pos,sub_len);
	printf("\n\tSub String is	:  ");
		printf("%s",sub_str);
	printf("\n\tEnter the string to be replaced : ");
	flushall();
	scanf("%[^\n]",rep);
	replace(str,rep,pos,sub_len);
	printf("\n\nAfter replacing string : %s",str);
	getch();
}
コード例 #20
0
ファイル: misc.c プロジェクト: QiuLihua83/minix2009
/*===========================================================================*
 *				fs_sync					     *
 *===========================================================================*/
PUBLIC int fs_sync()
{
/* Perform the sync() system call.  Flush all the tables. 
 * The order in which the various tables are flushed is critical.  The
 * blocks must be flushed last, since rw_inode() leaves its results in
 * the block cache.
 */
  register struct inode *rip;
  register struct buf *bp;

  /* Write all the dirty inodes to the disk. */
  for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++)
	if (rip->i_count > 0 && rip->i_dirt == DIRTY) rw_inode(rip, WRITING);

  /* Write all the dirty blocks to the disk, one drive at a time. */
  for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++)
	if (bp->b_dev != NO_DEV && bp->b_dirt == DIRTY) 
            flushall(bp->b_dev);

  return(OK);		/* sync() can't fail */
}
コード例 #21
0
ファイル: error.c プロジェクト: tombibsd/netbsd-src
/*
 * Exverror is called to raise the error exception.  If the second argument
 * is not NULL then error prints an error message using printf style
 * formatting.  It then raises the error exception.
 */
static __printflike(2, 0) void
exverror(int cond, const char *msg, va_list ap)
{
	CLEAR_PENDING_INT;
	INTOFF;

#ifdef DEBUG
	if (msg) {
		TRACE(("exverror(%d, \"", cond));
		TRACEV((msg, ap));
		TRACE(("\") pid=%d\n", getpid()));
	} else
		TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
#endif
	if (msg)
		exvwarning(-1, msg, ap);

	flushall();
	exraise(cond);
	/* NOTREACHED */
}
コード例 #22
0
ファイル: cache.c プロジェクト: wieck/minix
static void freeblock(struct buf *bp)
{
  ASSERT(bp->lmfs_count == 0);
  /* If the block taken is dirty, make it clean by writing it to the disk.
   * Avoid hysteresis by flushing all other dirty blocks for the same device.
   */
  if (bp->lmfs_dev != NO_DEV) {
	if (!lmfs_isclean(bp)) flushall(bp->lmfs_dev);
	assert(bp->lmfs_bytes == fs_block_size);
	bp->lmfs_dev = NO_DEV;
  }

  /* Fill in block's parameters and add it to the hash chain where it goes. */
  MARKCLEAN(bp);		/* NO_DEV blocks may be marked dirty */
  if(bp->lmfs_bytes > 0) {
	assert(bp->data);
	minix_munmap_t(bp->data, bp->lmfs_bytes);
	bp->lmfs_bytes = 0;
	bp->data = NULL;
  } else assert(!bp->data);
}
コード例 #23
0
ファイル: jobs.c プロジェクト: VargMon/netbsd-cvs-mirror
int
bgcmd(int argc, char **argv)
{
	struct job *jp;
	int i;

	nextopt("");
	do {
		jp = getjob(*argptr, 0);
		if (jp->jobctl == 0)
			error("job not created under job control");
		set_curjob(jp, 1);
		out1fmt("[%ld] %s", (long)(jp - jobtab + 1), jp->ps[0].cmd);
		for (i = 1; i < jp->nprocs; i++)
			out1fmt(" | %s", jp->ps[i].cmd );
		out1c('\n');
		flushall();
		restartjob(jp);
	} while (*argptr && *++argptr);
	return 0;
}
コード例 #24
0
ファイル: LAB16.C プロジェクト: dasasathyan/cbackup
void input(struct product *pro,int n,int i)
 {
   char num[10];
   if(i==n)return;
   head();
   flushall();
   printf("\n\n\n    Product # %d",i+1);
   do
   {
   printf("\n\n\n Enter Product Name : ");
   gets(pro->name);
   }while(alpha(pro->name)==0);
   do
   {
   printf("\n Enter Price : ");
   gets(num);
   }while(digit(num)==0);
   pro->price=atoi(num);

   input(pro+1,n,i+1);
 }
コード例 #25
0
ファイル: main.c プロジェクト: momodupi/VisualStudio
/**
  * @brief  随机生成初始种群
  * @param  popcurrent[CHROMNUM]: 染色体结构体数组
  * @retval 无
  */
void *evpop(chrom popcurrent[CHROMNUM])
{
	int i, j, value;
	int random;
	for (j = 0; j < CHROMNUM; j++)                            //从种群中的第1个染色体到第m个染色体
	{
		for (i = 0; i < CHROMPOS; i++)                        //从染色体的第1个基因位到第n个基因位
		{
			random = rand();                                  //生产0-1随机数
			random = (random % 2);                            
			popcurrent[j].bit[i] = random;                    //赋值到染色体
		}

		popcurrent[j].fit = y(x1(popcurrent[j]), x2(popcurrent[j]));              //计算染色体的适应度;
		//输出染色体编码
		printf("\n 染色体%d编码为: popcurrent[%d] = %d%d%d%d%d%d%d%d;", j, j, popcurrent[j].bit[7], popcurrent[j].bit[6], popcurrent[j].bit[5], popcurrent[j].bit[4], popcurrent[j].bit[3], popcurrent[j].bit[2], popcurrent[j].bit[1], popcurrent[j].bit[0]);
		printf("值为: [%d, %d]; 适应度为: %d", x2(popcurrent[j]), x1(popcurrent[j]), popcurrent[j].fit);
	}
	return(0);
	flushall();                                 //清除缓冲
}
コード例 #26
0
ファイル: nultermtest.c プロジェクト: C12331591/College-Work
main()
{
	char str[6];
	
	printf ("Type in a string.\n");
	gets(str);
	
	nulterm(6, str);
	
	if(str[5]=='\0')
	{
		printf ("\nstr is null terminated");
	}
	else
	{
		printf ("\nstr is not null terminated");
	}
	
	flushall();
	getchar();
}
コード例 #27
0
   void start()
   {
	  i=0;
	  init();
	  setcolor(WHITE);
	  settextstyle(1,0,4);
	  outtextxy(100,400,"Press any key to Continue");

	 if((f1=fopen("firstrun","r"))==NULL)
	  {
	   f1=fopen("firstrun","w+");
	   border();
	   while(!kbhit())
	   {
		if(i%2==0)
		 setcolor(GREEN);
		else
		 setcolor(BLACK);
		settextstyle(1,0,3);
		outtextxy(75,300,"Program is running for the first time");
		delay(500);
		i++;
	   }
	   f2=fopen("Admin","wb+");
	   f3=fopen("data.dat","wb+");
	   f5=fopen("rem_acc.dat","wb+");
	   f6=fopen("password.dat","wb+");
	   df=fopen("cust.dat","wb+");
	   ft=fopen("transactions","wb+");
	   strcpy(admin.loginid,"admin");
	   strcpy(admin.password,"password");
	   fwrite(&admin,sizeof(admin),1,f2);
	   data.acc_no=10001;
	   data.tran_no=1000000;
	   fwrite(&data,sizeof(data),1,f3);
	   flushall();
	   fcloseall();
	  }
	  getch();
   }
コード例 #28
0
ファイル: 结构体_2.c プロジェクト: Oscer2016/Program
int main(void)
{
	struct student stu;
	int i,sum=0;
	printf("please input the information:\n");
	printf("please input num:");
	scanf("%s",&stu.num);
	printf("please input name:");
	scanf("%s",&stu.name);
	printf("please input sex:");
	flushall();					//清除输入缓存区,以便正确输入性别
	scanf("%c",&stu.sex);
	printf("please input age:");
	scanf("%d",&stu.age);
	printf("please input birthday:");
	scanf("%d%d%d",&stu.birthday.year,&stu.birthday.month,&stu.birthday.day);
	printf("please input scores:");
	
	//循环输入该学生的三门成绩
	for (i=0; i<3; i++)
		scanf("%d",&stu.score[i]);
	
	//计算该学生三门成绩的总和
	for (i=0; i<3; i++)
		sum += stu.score[i];
	
	//计算该学生三门成绩的平均值
	stu.aver = sum / 3.0;
	printf("\nthe information is:");
	printf("\nthe num is %s",stu.num);
	printf("\nthe name is %s",stu.name);
	printf("\nthe sex is %c",stu.sex);
	printf("\nthe age is %d",stu.age);
	printf("\nthe birthday is %02d-%02d-%02d",stu.birthday.year,
			stu.birthday.month,stu.birthday.day);
	printf("\nthe score is:");
	for (i=0; i<3; i++)
		printf("%d ",stu.score[i]);
	printf("\nthe aver is %.2f\n",stu.aver);
}
コード例 #29
0
ファイル: Main.c プロジェクト: Kefirchiks/C_DynStruct
// f-ja ierakstu meklesanai
void meklet() {
	int i, *sk = NULL, r = 0;
	// i - skaititajs; sk - atrasto ierakstu nr; r - atrasto ierakstu skaits
	char search[21]; // search - meklesanas atslegas vards
	// parbauda, vai biblioteka ir kads ieraksts
	if (bibl == NULL)
		printf("Datubaze ir tuksa!");
	else {
		// pieprasa ievadit bibl. nosaukumu
		printf("Ievadiet bibliotekas nosaukumu, pec kura meklet bibliotekas:\t"
			);
		flushall();
		gets(search); // nolasa bibl. nosaukumu
		// cikla atrod, vai ir kads bibl. nosaukums
		for (i = 0; i < izm; i++)
			if (strstr(bibl[i].nosaukums, search) != NULL) {
				r++; // palielina atrasto el. skaitu par 1
				sk = (int*)realloc(sk, r*sizeof(int));
				sk[r - 1] = i; // ievad elementa numuru sk masiva
			}
		// izvada pazinojumu, ja nekas netika atrasts
		if (r == 0)
			printf("Pec jusu ievadita atslegas varda '%s' nekas netika atrasts!"
			, search);
		// izvada atrastos elementus
		else {
			printf("Pec jusu ievadita atslegas varda '%s' tika atrast(s/i) %d ieraksti!"
				, search, r);
			for (i = 0; i < r; i++) {
				printf("\n\n%d. ieraksts:", i + 1);
				printf("\nAdrese: %s", bibl[sk[i]].adrese);
				printf("\nNosaukums: %s", bibl[sk[i]].nosaukums);
				printf("\nID: %d", bibl[sk[i]].id);
				printf("\nGramatu skaits: %d", bibl[sk[i]].skaits);
			}
		}
		printf("\n\nNospiediet jebkuru taustinu, lai turpinatu!");
		getch();
	}
}
コード例 #30
0
ファイル: assignment.c プロジェクト: C12331591/College-Work
void del()
{
	struct employee current;
	FILE *search;
	FILE *mark;
	search=fopen("employees.dat", "rb");
	mark=fopen("employees.dat", "ab");
	int found=0;
	char input[6];
	
	printf ("\nPlease enter the number of the employee to be deleted.\n");
	scanf ("%5s", &input);
	flushall();
	
	fseek(search, HEADERSIZE, SEEK_SET);
	
	while(fread(&current, RECSIZE, 1, search)!=NULL && found==0)
	{
		if(strcmp(current.emp_num, input)==0)
		{
			found=1;
			mark=search;
		}
	}//end while
	
	if (found==0)
	{
		printf ("\nThe specified employee number does exist in the file.\n\n");
	}
	else
	{
		current.emp_num[0]='*';
		fwrite(&current, RECSIZE, 1, mark);
		update(0, 1);
	}
	
	fclose(search);
	fclose(mark);
}//end del()