[求助]关于split地用法,紧急!!
各位大大,
我是新手,有个问题啊,帮帮忙啊, 不太会用split, 下面的问题搞不定 帮帮忙拉!
题目:
一份员工文件报还的记录, 显示雇员的身份号码,姓氏,名字,工作代码 和 支付代码。
工作代码相对应工作职位, 支付代码相对于工资
工作代码 工作职位名称
A80 clerk
A90 Word processor
B30 Accountant
B50 Programmer
B70 Systems Analyst
C20 Engineer
C40 Senior engineer
D50 Manager
D60 Financial analyst
支付代码 工资
P01 $9.00
P02 $9.50
p03 $12.00
p04 $20.00
p05 $23.50
p06 $27.00
p07 $33.00
p08 $40.00
Employee.txt
员工号 姓氏 名字 工作代号 支付代码
s698790 Penato Maria D50 P08
s656780 Lee Jessica B70 P05
s409872 Lawson Henry B50 P07
s687890 Steel Andrew A90 P03
s456432 Anderson John B50 P07
s645690 Zivak Nikola C20 P06
s456432 Anderson Mary B50 P07
s453890 White Jenny D60 P06
s457542 Tyaeb Tauhid B50 P07
s598762 Simin Jia A80 P04
目标输出是: result2.txt
员工号 姓氏 名字 工作职位名称 工资
s698790 Penato Maria ? ?
s656780 Lee Jessica
s409872 Lawson Henry
s687890 Steel Andrew
s456432 Anderson John
s645690 Zivak Nikola
s456432 Anderson Mary
s453890 White Jenny
s457542 Tyaeb Tauhid
我写的代码:
#include<stdio.h>#include<string.h>#define SIZE 10int main(void){char line[SIZE], *status;FILE *infile, *outfile;infile = fopen("Employee.txt","r");outfile =fopen("result2.txt""w");status = fgets(line, SIZE, infile);while (status != NULL){ fputs(line, outfile); fputs(line, stdout); status = fgets(line, SIZE, infile); }fclose(infile);fclose(outfile);system("pause");return 0;}