讀寫文件一般都用fread和fwrite 打開的時候一般用rb或wb 二進制打開。
成都創新互聯公司是一家集網站建設,石拐企業網站建設,石拐品牌網站建設,網站定制,石拐網站建設報價,網絡營銷,網絡優化,石拐網站推廣為一體的創新建站企業,幫助傳統企業提升企業形象加強企業競爭力。可充分滿足這一群體相比中小企業更為豐富、高端、多元的互聯網需求。同時我們時刻保持專業、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們為更多的企業打造出實用型網站。
check函數中的ends變量需要初始化一下!
int check(char* a){
printf("begins");
int j;
int begins=0;
int ends = 0;// 在這里把ends初始化一下就OK了!
printf("begins");
for(j=0;jstrlen(a);j++){
if(*(a+j)==' '*(a+j-1)!=' ') ends = j-1;
if(*(a+j)==' '*(a+j+1)!=' ') begins = j+1;
reverse(a,begins,ends);// 因為你每次調用這個函數的時候,只有ends或begins中的一個被賦值,如此,如果ends沒有被初始化,編譯器就會報警!
}//for循環結束
printf("ends");
return 0;
}
改動如下:
#include stdio.h
#includestring.h
enum gender
{
male,famale
};
typedef struct course
{
char coursename[10];
int coursescore;
}STC;
typedef struct student
{
long studentnumber;
char name[20];
int age;
enum gender sex;
STC coursescore[3];
struct student *next;
void (*ptooutput)(struct student*); // 改動1:改成指針,與output函數匹配
}STD;
void output(struct student *p)
{
int i;
printf("學生%s:\n",p-name);
printf("他的學號是%ld\n",p-studentnumber); // 改動2:學號
printf("他的年齡是%d\n",p-age); // 改動3:年齡
if(p-sex==0)
{printf("他的性別是男\n");}
else
{printf("他的性別是女\n");}
for(i=0;i3;i++)
{
printf("他的%s",p-coursescore[i].coursename);
printf("成績是%d\n",p-coursescore[i].coursescore);
}
}
main()
{
STD a;
a.studentnumber=1011110201;
strcpy(a.name,"葉超");
a.age=19;
a.sex=male;
strcpy(a.coursescore[0].coursename,"數學");
a.coursescore[0].coursescore=87;
strcpy(a.coursescore[1].coursename,"英語");
a.coursescore[1].coursescore=72;
strcpy(a.coursescore[2].coursename,"C語言");
a.coursescore[2].coursescore=66;
a.ptooutput = output; // 改動4:設置打印函數指針
a.ptooutput(a); // 改動5:輸入參數為指針
}
文章題目:c語言core函數 c語言中creat函數
文章網址:http://m.newbst.com/article8/dopphip.html
成都網站建設公司_創新互聯,為您提供網站排名、App設計、網站收錄、企業建站、云服務器、標簽優化
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯