123;342;543;36.6;calm
。然后使用函数atoi()
来比较我的值。但第一个我想使用strtok()。我不明白这有什么问题,因为我只能使用printf("%s",str);
,但我无法正确使用strtok()
这就是为什么我没有得到我的结果。
CODE:
void printInfo()
{
int i;
FILE *out;
char str[250];
char sp[10]=";";
char *istr;
istr=strtok(str,sp);
if ((out =fopen("test.txt","r"))==NULL)
printf("Error open, file\n");
else
{
fgets(str,250,out);
printf("%s",str);
while (istr != NULL)
{
printf("%s",istr);
istr=strtok(NULL,sp);
}
}
fclose(out);
}
答案 0 :(得分:5)
您的第一次-- Both of these will return the same result:
select datediff(day,
,StartDate
,coalesce(EndDate, getdate())
)
,datediff(day,
,StartDate
,isnull(EndDate, getdate())
)
来电是在错误的地方。必须在字符串strtok()
收到有效内容之后,即在str
之后。
这对fgets()
更容易,更清洁,更安全。
答案 1 :(得分:3)
istr=strtok(str,sp);
读取数据后应该调用