91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 891B
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-10
  • 語言: C/C++
  • 標簽: 數據??讀取??txt??鏈表??

資源簡介

從文本文件中讀取數據并自動建立單鏈表 另一個完整的程序 http://download.csdn.net/source/3198575 VC++6.0環境下編譯通過

資源截圖

代碼片段和文件信息

#include?“stdio.h“
#include?“malloc.h“

//定義學生結構體
struct?student
{
char????name[16];
long num;
int? age;
char sex;
float? score;

};

//定義單鏈表結點
typedef?struct?listnode ?
{
struct?student?stu;
struct?listnode?*next;
}node;


void?main()
{

????node?*head*end*p;
FILE?*fp;
int?i=0;


head?=?(node?*)malloc(sizeof(node));
p=head;
p->next=NULL;

fp=fopen(“data.txt““r“);

//判斷文件是否結束
while(!feof(fp))
{ //尾插法建立單鏈表
end?=?(node?*)malloc(sizeof(node));
p->next=end;
p=end;
p->next=NULL;
//讀取數據
fscanf(fp“%s?%ld?%d?%c?%f“&p->stu.name&p->stu.num&p->stu.age&p->stu.sex&p->stu.score);
}
fclose(fp);
printf(“Data?import?successfully\n“);


p=head->next;
printf?(“\nnode????name?\t?\tnum\tage\tsex\t?score\n“);
while(NULL!=p->next)
{ i++;
printf?(“%d\t%-16s%-8d%d\t%-c\t%6.2f\n“ip->stu.namep->stu.nump->stu.agep->stu.sexp->stu.score);
p=p->next;
}

}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????110??2011-03-26?16:37??TxtAndList\data.txt

?????文件????????988??2011-03-26?16:33??TxtAndList\list_create_test3.cpp

?????目錄??????????0??2011-03-26?16:37??TxtAndList

-----------?---------??----------?-----??----

?????????????????1098????????????????????3


評論

共有 條評論