avatar
how to sscanf this case.# Unix - 噫吁兮,危乎高哉
h*o
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,
avatar
D*u
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。