h**o 发帖数: 548 | 1 I want to have a input string parsed by sscanf (or other function which
can work) using solaris C language in this way:
if the first part of the string is less than 10bytes, parse it and
assign it to a variable;
if the first part of the string is more than 10bytes, truncate it and
assign it to a variable.
Her is my expected result:
suppose input[] = "ThisStringFieldShouldBeTruncated 123
OtherStringFieldWhichAlsoShouldBeTruncated 456";
I want to parse it to
char v1[11]="ThisString"; int b1= 123, | D**u 发帖数: 179 | 2 use the second format
and use a temp variable to read the first, possible long string,
say
char buffer[800];
then strncpy (...) from buffer to v1
【在 h**o 的大作中提到】 : I want to have a input string parsed by sscanf (or other function which : can work) using solaris C language in this way: : if the first part of the string is less than 10bytes, parse it and : assign it to a variable; : if the first part of the string is more than 10bytes, truncate it and : assign it to a variable. : Her is my expected result: : suppose input[] = "ThisStringFieldShouldBeTruncated 123 : OtherStringFieldWhichAlsoShouldBeTruncated 456"; : I want to parse it to
|
|