其他分享
首页 > 其他分享> > c语音写入文件

c语音写入文件

作者:互联网

#include<stdio.h>
#include<stdlib.h>
#include<cmath>
int main() {
FILE *fp,*fp1;
int pid; int ji,pri;
struct {
int sum;
int jifi[800];
char statu[800];}w[20];
fopen_s(&fp,"LOG.txt", "r");
fopen_s(&fp1, "1.txt", "a");
for (int i = 7; i <= 19; i++) {
w[i].sum = -1;}
char stat;
while (fscanf_s(fp, "%d %c %d %d", &pid, &stat,1, &ji,&pri)!=EOF)
{
if (pid >= 7 && pid <= 19) {
w[pid].sum++;
w[pid].jifi[w[pid].sum] = ji;
w[pid].statu[w[pid].sum] = stat;
}
}
for (int i = 7; i <= 19; i++)
{
for (int j = 0; j <=w[i].sum; j++) {
fprintf_s(fp1,"%d %c %d\n",i,w[i].statu[j],w[i].jifi[j]);
}
}

/* int flag = 0; int flag1 = 0; int flag2 = 0;
for (int i = 7; i <= 19; i++) {
flag = 0; flag1 = 0; flag2 = 0;
for (int j = 0; j <= w[i].sum; j++) {
if (w[i].statu[0] != 'N'||w[i].statu[1] != 'J'&&!flag1) {
printf("pid:%d进程出错错误在第%d行\n", i,j); flag = 1;
flag1 = 1;
}
else if (w[i].statu[w[i].sum] != 'E'&&!flag2) {
printf("pid:%d进程出错错误在第%d行\n", i,j); flag = 1; }
else if (j>=2&&j< w[i].sum) {
if (!((w[i].statu[j - 1] == 'R'&&w[i].statu[j] == 'J') || (w[i].statu[j - 1] == 'J'&& w[i].statu[j] == 'R') || (w[i].statu[j - 1] == 'R'&&w[i].statu[j] == 'W') || (w[i].statu[j - 1] == 'W'&&w[i].statu[j] == 'J')))
{
printf("pid=%d进程状态出错错误在第%d行\n", i,j); flag = 1;
}
}


}if (flag == 0)printf("pid:%d进程状态记录准确\n",i);
}
*/
fclose(fp);
fclose(fp1);
return 0;}

标签:文件,statu,&&,int,pid,sum,写入,flag,语音
来源: https://www.cnblogs.com/hahaah/p/14981212.html