解析较小字符串中的大字符串。 [英] parsing a big string in smaller strings.

查看:100
本文介绍了解析较小字符串中的大字符串。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我要解析一个大字符串


char Big_String [150];


变成小字符串


char Small_String [30] [5];

我的意思是说Small_String用<中的空格分隔br />
Big_String我希望将它们保存在五个不同的

Small_Strings中。 Big_String中可能有1,2,3 4或5 [最大] Small_Strings




请为我编写一个紧凑的子程序。


TIA,

Shishir

解决方案

周五, 2007年11月16日03:08:15 -0800(太平洋标准时间),Shishir

< sh ********* @ gmail.comwrote:


我想解析一个大字符串


char Big_String [150];


成小字符串


char Small_String [30] [5];


我的意思是说,Small_String在
Big_String中用空格分隔,我想要将它们保存在五个不同的
Small_Strings中。 Big_String中可能存在1,2,3 4或5 [最大] Small_Strings

请为我编写一个紧凑的子程序。



我有一个更好的主意。你写下来,然后问你是否/什么时候卡住了。

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

-

PGP密钥ID 0xEB7180EC


Shishir写道:


大家好,


我想解析一个大字符串


char Big_String [150];


变成小字符串


char Small_String [30] [5];


我的意思是说Small_String用空格分隔

Big_String我希望将它们保存在五个不同的

Small_Strings中。 Big_String中可能存在1,2,3 4或5 [最大] Small_Strings




那你为什么要为每个最多4个字节的30个

字符串声明Small_String呢?


请为我编写一个紧凑的子程序。



我们根据要求不倾向于做作业......


Shishir写道:


大家好,


我想解析一个大字符串


char Big_String [150];



(Nitpick:那不是一个字符串;它是一个字符串数组。

它不是一个字符串除非里面有空终止。)


(Stylepick:可以使用camelCase;可以使用underlined_form;

同时尝试使用它们似乎是一个计算好的
marmite冰淇淋。)


成小串


char Small_String [30] [5];


我的意思是说,Small_String由

Big_String中的空格分隔,我想将它们保存在五种不同的

Small_Strings。 Big_String中可能存在1,2,3 4或5 [最大] Small_Strings




所以大字符串中有空格分隔的小字符串,好的。


请写一个紧凑的子程序对我来说。



这不是Do Me Work For Me组。但我建议你看看

[规范]标准函数`strtok`。


-

Chris def compact()=();" Dollin


Hewlett-Packard Limited注册号:

注册办事处:Cain Road,Bracknell,Berks RG12 1HN 690597英格兰


Hi All,

I want to parse a big string

char Big_String[150];

into small strings

char Small_String[30][5] ;
I mean to say that Small_String are separated by spaces in the
Big_String and i want to save them them in five different
Small_Strings. There may be 1,2,3 4 or 5 [ at max] Small_Strings
present in the Big_String.

Please write a compact subroutine for me.

TIA,
Shishir

解决方案

On Fri, 16 Nov 2007 03:08:15 -0800 (PST), Shishir
<sh*********@gmail.comwrote:

I want to parse a big string

char Big_String[150];

into small strings

char Small_String[30][5] ;
I mean to say that Small_String are separated by spaces in the
Big_String and i want to save them them in five different
Small_Strings. There may be 1,2,3 4 or 5 [ at max] Small_Strings
present in the Big_String.

Please write a compact subroutine for me.

I''ve got a better idea. You write it, then ask if/when you get stuck.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2
--
PGP key ID 0xEB7180EC


Shishir wrote:

Hi All,

I want to parse a big string

char Big_String[150];

into small strings

char Small_String[30][5] ;
I mean to say that Small_String are separated by spaces in the
Big_String and i want to save them them in five different
Small_Strings. There may be 1,2,3 4 or 5 [ at max] Small_Strings
present in the Big_String.

Then why have you declared Small_String as appropriate for 30 strings of
at most 4 bytes each?

Please write a compact subroutine for me.

We don''t tend to do homework on request...


Shishir wrote:

Hi All,

I want to parse a big string

char Big_String[150];

(Nitpick: that''s not automatically a string; it''s a char array.
It''s not a string unless there''s null termination inside it.)

(Stylepick: one can use camelCase; one can use underlined_form;
trying to use them both simultaneously seems to be a computational
marmite ice-cream.)

into small strings

char Small_String[30][5] ;
I mean to say that Small_String are separated by spaces in the
Big_String and i want to save them them in five different
Small_Strings. There may be 1,2,3 4 or 5 [ at max] Small_Strings
present in the Big_String.

So the big string has space-separated small strings in it, OK.

Please write a compact subroutine for me.

This is not a Do My Work For Me group. But I suggest that you look at
the [specification of the] standard function `strtok`.

--
Chris "def compact() =();" Dollin

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England


这篇关于解析较小字符串中的大字符串。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆