想用sccanf分割字符串,以下能够正常
sscanf("111,2009-1-1 00:00:00,333,444,555@","%[^,],%[^,],%[^,],%[^,],%[^@]@",str0,str1,str2,str3,str4)但是如果是
sscanf("111,2009-1-1 00:00:00,,444,555@","%[^,],%[^,],%[^,],%[^,],%[^@]@",str0,str1,str2,str3,str4)
只能取到str0 str1我想后面的str3,str4也能取出来,用sscanf能实现吗?有其他好方法吗?
sscanf("111,2009-1-1 00:00:00,333,444,555@","%[^,],%[^,],%[^,],%[^,],%[^@]@",str0,str1,str2,str3,str4)但是如果是
sscanf("111,2009-1-1 00:00:00,,444,555@","%[^,],%[^,],%[^,],%[^,],%[^@]@",str0,str1,str2,str3,str4)
只能取到str0 str1我想后面的str3,str4也能取出来,用sscanf能实现吗?有其他好方法吗?
还是用其他方法吧,我们编程的目标就是为了方法更简单,用strtok吧,支持楼上
//除非处理前将",,"替换为" "之类的。
//支持用strtok