由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - how to sscanf this case.
相关主题
[转载] any fast way to learn Yak? (bison and flex)Shell Question
[转载] C 语言输入函数紧急求助!请教一个shell script的问题
how to change environment size in IRIX?Help on get an integer from a date string
How to input chinese in cxterm?[转载] Perl text parsing
a question about emacs[转载] CVS question
awk questionSolaris底下没有类似getopt_long的call?
equivilent $REMOTEHOST in kshA question about symbolic link
帮帮忙,用C作一个SHELLYACC tables (yyact, yypact, yypgo ...) 的问题 (转载)
相关话题的讨论汇总
话题: sscanf话题: string话题: 10bytes话题: variable话题: parse
进入Unix版参与讨论
1 (共1页)
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

1 (共1页)
进入Unix版参与讨论
相关主题
YACC tables (yyact, yypact, yypgo ...) 的问题 (转载)a question about emacs
脚本编程求助: BC的使用awk question
unix/linux schedule problem, need high end to help.equivilent $REMOTEHOST in ksh
how to change the date attribute of a file帮帮忙,用C作一个SHELL
[转载] any fast way to learn Yak? (bison and flex)Shell Question
[转载] C 语言输入函数紧急求助!请教一个shell script的问题
how to change environment size in IRIX?Help on get an integer from a date string
How to input chinese in cxterm?[转载] Perl text parsing
相关话题的讨论汇总
话题: sscanf话题: string话题: 10bytes话题: variable话题: parse