怪!怪!怪!怪!怪!

ebfm 2003-04-15 04:09:48
#include <stdio.h>

main()
{
FILE * input_file_p;/* File Pointer for the input file */
char tmp;
char tmpbuff[256];
int usage[24][60];
int i;
int hour_1, min_1, hour_2, min_2;

input_file_p = fopen("testing.log", "r");

if (input_file_p == NULL)
{
printf("cannot open file testing.log\n");
exit(1);
}

for( i=0; i<24; i++)
{
memset( usage[i], 0, sizeof(60));
}

while (fgets( tmpbuff, sizeof(tmpbuff), input_file_p ) != NULL)
{
char tmp[64];

/* get 1st hour number */
strcpy(tmp, &tmpbuff[47], 2);
tmp[3] = '\0';
hour_1 = atoi(tmp);

/* get 1st min number */
strcpy(tmp, &tmpbuff[50], 2);
tmp[3] = '\0';
min_1 = atoi(tmp);

/* get 2st hour number */
strcpy(tmp, &tmpbuff[63], 2);
tmp[3] = '\0';
hour_2 = atoi(tmp);

/* get 2st min number */
strcpy(tmp, &tmpbuff[66], 2);
tmp[3] = '\0';
min_2 = atoi(tmp);

printf("%d %d %d %d\n", hour_1, min_1, hour_2, min_2);

}

}

为什么只能输出[47]第一个的值?后面三个值呢?
...全文
28 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ebfm 2003-04-15
  • 打赏
  • 举报
回复
6千多行的值都出来了???
catyou 2003-04-15
  • 打赏
  • 举报
回复
都有值, 打印出来是正确的
langzi8818 2003-04-15
  • 打赏
  • 举报
回复
那里错了?
skywarship 2003-04-15
  • 打赏
  • 举报
回复
程序应该没有错误才对
skywarship 2003-04-15
  • 打赏
  • 举报
回复
返回是怎样的,只有一个值,那其余三个是没有任何显示还是其他什么
catyou 2003-04-15
  • 打赏
  • 举报
回复
你要输出哪三个值?我测了一下, 可以输出啊,
程序中的strcpy是不是写错了, 应是strncpy吧

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧