學(xué)會(huì)對(duì)文件的記錄鎖定,及解鎖。#include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { int fd int i struct { char name[20] uint ID int age } myrec fd =open("name", O_RDWR|O_CREAT, 0755) if (fd == -1) return -1 printf("Input your name:") scanf("%s", myrec.name) printf("Inpute your ID :") scanf("%d", &myrec.ID) printf("Input your age :") scanf("%d", &myrec.age) lseek(fd, 0,SEEK_END) lockf(fd, 1, 0) write(fd, (void *)&myrec, sizeof(myrec)) lockf(fd, 0 ,0) return 0 } 執(zhí)行命令cc lock.c –o lock.out Chmod +x lock.out ./lock.out
標(biāo)簽: 記錄
上傳時(shí)間: 2016-01-04
上傳用戶:亞亞娟娟123
Status CreateSMatrix(RLSMatrix &M) { // 創(chuàng)建稀疏矩陣M int i Triple T Status k printf("請(qǐng)輸入矩陣的行數(shù),列數(shù),非零元素?cái)?shù):") scanf("%d,%d,%d",&M.mu,&M.nu,&M.tu) M.data[0].i=0 // 為以下比較做準(zhǔn)備 for(i=1 i<=M.tu i++) { do {
標(biāo)簽: Status CreateSMatrix RLSMatrix Triple
上傳時(shí)間: 2013-12-22
上傳用戶:shanml
C語(yǔ)言的名里使用方法,包括輸入輸出函數(shù),scanf,printf,define,還有ASCII碼表
標(biāo)簽: C語(yǔ)言
上傳時(shí)間: 2014-01-04
上傳用戶:
S3C2410開發(fā)實(shí)驗(yàn)源代碼及實(shí)驗(yàn)指導(dǎo);內(nèi)容包括: LED_ON LED_ON_C IO_ports arm-linux-ld memory_controller Nand Flash controller uart printf,scanf interrupt controller timer mmu clock vivi等; 主要講述了單片機(jī)s3c2410的使用。
標(biāo)簽: memory_controller arm-linux-ld IO_ports LED_ON_C
上傳時(shí)間: 2013-12-21
上傳用戶:851197153
printf(" 請(qǐng)輸入%d個(gè)課程的代表值(<%d個(gè)字符):\n" ,(*G).vexnum,MAX_NAME) for(i=0 i<(*G).vexnum ++i) /* 構(gòu)造頂點(diǎn)向量 */ { scanf(" %s" ,(*G).vertices[i].data) (*G).vertices[i].firstarc=NULL } printf(" 請(qǐng)輸入%d個(gè)課程的學(xué)分值(<%d個(gè)字符):\n" ,(*G).vexnum,MAX_NAME) for(i=0 i<(*G).vexnum ++i) /* 構(gòu)造頂點(diǎn)向量 */ {scanf(" %s" ,(*G).verticestwo[i].data) } printf(&quo
標(biāo)簽: vexnum quot MAX_NAME printf
上傳時(shí)間: 2016-08-15
上傳用戶:Avoid98
成績(jī)顯示三個(gè)部份abc #include<stdio.h> #include<stdlib.h> int main(void) { float gread printf("請(qǐng)輸入分?jǐn)?shù)\n") scanf("%f",&gread) if(gread>=80&&gread<=100) printf("成績(jī)?yōu)锳\n") else if(gread>=60&&gread<=79) { printf("成績(jī)?yōu)锽\n") } else if(gread>=0&&gread<60) { printf("成績(jī)?yōu)镃\n") } else { printf("分?jǐn)?shù)輸入錯(cuò)誤\n") } system("pause") return 0 }
標(biāo)簽: include stdlib float gread
上傳時(shí)間: 2014-01-15
上傳用戶:waizhang
河內(nèi)塔問(wèn)題 #include<stdio.h> #include<stdlib.h> int fun_a(int) void fun_b(int,int,int,int) int main(void) { int n int option printf("題目二:河內(nèi)塔問(wèn)題\n") printf("請(qǐng)輸入要搬移的圓盤數(shù)目\n") scanf("%d",&n) printf("最少搬移的次數(shù)為%d次\n",fun_a(n)) printf("是否顯示移動(dòng)過(guò)程? 是請(qǐng)輸入1,否則輸入0\n") scanf("%d",&option) if(option==1) { fun_b(n,1,2,3) } system("pause") return 0 } int fun_a(int n) { int sum1=2,sum2=0,i for(i=n i>1 i--) { sum1=sum1*2 } sum2=sum1-1 return sum2 } void fun_b(int n,int left,int mid,int right) { if(n==1) printf("把第%d個(gè)盤子從第%d座塔移動(dòng)到第%d座塔\n",n,left,right) else { fun_b(n-1,left,right,mid) printf("把第%d個(gè)盤子從第%d座塔移動(dòng)到第%d座塔\n",n,left,right) fun_b(n-1,mid,left,right) } }
標(biāo)簽: int include stdlib fun_a
上傳時(shí)間: 2016-12-08
上傳用戶:努力努力再努力
函數(shù)分庫(kù)函數(shù)和用戶自定義函數(shù)兩類: 庫(kù)函數(shù)(又稱系統(tǒng)函數(shù))是高級(jí)語(yǔ)言軟家中提供基礎(chǔ)功能的函數(shù)。庫(kù)函數(shù)文件以h為文件后綴,如C語(yǔ)言的stdio.h文件包括了printf(), scanf (),open(),close()。C語(yǔ)言中主函數(shù)要使用某庫(kù)函數(shù):#include<庫(kù)函數(shù)文件名>
標(biāo)簽: 函數(shù) 庫(kù)函數(shù) 分 家
上傳時(shí)間: 2014-01-04
上傳用戶:sy_jiadeyi
①把settle定義成char型變量 ②settle=(settle>= A && settle <= B ) 寫錯(cuò)了,改成(settle>= A && settle <= Z ) ③scanf函數(shù)后面加一句getchar()用來(lái)吸收回車鍵
上傳時(shí)間: 2017-04-21
上傳用戶:moshushi0009
兩個(gè)鏈表的交集 #include<stdio.h> #include<stdlib.h> typedef struct Node{ int data; struct Node *next; }Node; void initpointer(struct Node *p){ p=NULL; } int printlist(struct Node* head){ int flag=1; head=head->next; /* 因?yàn)闃?biāo)記1的地方你用了頭結(jié)點(diǎn),所以第一個(gè)數(shù)據(jù)域無(wú)效,應(yīng)該從下一個(gè)頭元結(jié)點(diǎn)開始 */ if(head==NULL) printf("NULL\n"); else { while(head!=NULL) { if(flag==1) { printf("%d",head->data); flag=0; } else { printf(" %d",head->data); } head=head->next; } printf("\n"); } return 0; } struct Node *creatlist(struct Node *head) { int n; struct Node *p1=(struct Node *)malloc(sizeof(struct Node)); p1->next=NULL; while(scanf("%d",&n),n!=-1) { struct Node *pnode=(struct Node *)malloc(sizeof(struct Node)); pnode->next=NULL; pnode->data=n; if(head==NULL) head=pnode; p1->next=pnode; p1=pnode; } return head; } struct Node *Intersect(struct Node *head1, struct Node *head2) { struct Node *p1=head1,*p2=head2;/*我這里沒(méi)有用頭指針和頭結(jié)點(diǎn),這里是首元結(jié)點(diǎn)head1里面就是第一個(gè)數(shù)據(jù),一定要理解什么事頭指針, 頭結(jié)點(diǎn),和首元結(jié)點(diǎn) 具體你一定要看這個(gè)博客:http://blog.sina.com.cn/s/blog_71e7e6fb0101lipz.html*/ struct Node *head,*p,*q; head = (struct Node *)malloc(sizeof(struct Node)); head->next = NULL; p = head; while( (p1!=NULL)&&(p2!=NULL) ) { if (p1->data == p2->data) { q = (struct Node *)malloc(sizeof(struct Node)); q->data = p1->data; q->next = NULL; p->next = q;//我可以認(rèn)為你這里用了頭結(jié)點(diǎn),也就是說(shuō)第一個(gè)數(shù)據(jù)域無(wú)效 **標(biāo)記1** p = q; p1 = p1->next; p2 = p2->next; } else if (p1->data < p2->data) { p1 = p1->next; } else { p2 = p2->next; } } return head; } int main() { struct Node *head=NULL,*headt=NULL,*t; //initpointer(head);//這里的函數(shù)相當(dāng)于head=NULL; // initpointer(headt);//上面已經(jīng)寫了headt=NULL那么這里可以不用調(diào)用這個(gè)函數(shù) head=creatlist(head); headt=creatlist(headt); t=Intersect(head,headt); printlist(t); }
標(biāo)簽: c語(yǔ)言編程
上傳時(shí)間: 2015-04-27
上傳用戶:coco2017co
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1