336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
#include
#define MAX 100
int main(void)
{
FILE* stream; // 파일 포인터 생성
char bufferString[100];
char tempString[100];
char day[200][15];
char time[200][10];
int data[200][10];
int dataAverage[10]= {0};
int i, j, totalCount = 0;
char *token;
char* delimeter = ",";
stream = fopen("data3.txt","a+");
// 파일 열기
// 키보드로 입력 받아 buffer에 저장
fseek(stream,0,SEEK_SET);
fscanf(stream,"%s", bufferString);
fscanf(stream,"%s", bufferString);
fscanf(stream,"%s", bufferString);
fscanf(stream,"%s", bufferString);
// 원하는 SEEK 에 도달
while(!feof(stream))
{
fscanf(stream,"%s", tempString);
// 2013-12-07
fscanf(stream,"%s", bufferString);
// 09:02:55,56,82,30,56,80,25,55,80,24,230
strcat(tempString, ",");
strcat(tempString, bufferString);
//printf("%s\n", tempString);
i = 0;
j = 0;
token = strtok(tempString, delimeter);
while(token != NULL)
{
printf("%s\n", token);
switch(i)
{
case 0:
strcpy(day[totalCount],token);
break;
case 1:
strcpy(time[totalCount],token);
break;
default:
data[totalCount][j] = atoi(token);
j++;
break;
}
token = strtok(NULL, delimeter); //토큰으로 분리할 문자가 없는경우 NULL리턴
i++;
}
totalCount++;
}
printf("Data Count : %d\n", totalCount );
printf("%7s %7s %7s %7s %7s %7s %7s %7s %7s %7s\n"
, "LT-101","PT-101","TE-101","LT-102","PT-102","TE-102","LT-103","PT-103","TE-103","MFM-101");
for( j = 0 ; j < 10 ; j++ )
{
for( i = 0 ; i < totalCount ; i++ )
{
dataAverage[j] += data[i][j];
}
}
for( j = 0 ; j < 10 ; j++ )
{
for( i = 0 ; i < totalCount ; i++ )
{
if( data[i][j]>(dataAverage[j] / totalCount)*2)
{
printf("ERROR!!! %s %s 에 발생한 에러! \n", day[i], time[i]);
}
}
}
printf("%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf"
, (double)dataAverage[0] / totalCount
, (double)dataAverage[1] / totalCount
, (double)dataAverage[2] / totalCount
, (double)dataAverage[3] / totalCount
, (double)dataAverage[4] / totalCount
, (double)dataAverage[5] / totalCount
, (double)dataAverage[6] / totalCount
, (double)dataAverage[7] / totalCount
, (double)dataAverage[8] / totalCount
, (double)dataAverage[9] / totalCount
);
// 파일(stream)에 buffer 내용 쓰기
fclose(stream);
// 파일(stream) 닫기
return 0;
}