C/C++
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs C/C++

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old November 16th, 2007, 08:39 AM
Shishir
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
parsing a big string in smaller strings.

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


Reply With Quote
  #2  
Old November 16th, 2007, 08:39 AM
Mark Bluemel
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
parsing a big string in smaller strings.

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

Reply With Quote
  #3  
Old November 16th, 2007, 08:39 AM
Chris Dollin
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
parsing a big string in smaller strings.

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, K.

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


Reply With Quote
  #4  
Old November 16th, 2007, 09:19 AM
Mark Bluemel
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
parsing a big string in smaller strings.

Chris Dollin wrote:
Shishir wrote:
>


>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.


But I suggest that you look at
the [specification of the] standard function `strtok`.
>


I was considering an evil solution, writing the original string to a
file, converting space to EL on output and then reading the file a line
at a time

Reply With Quote
Reply

Viewing: Web Development Archives FAQs C/C++ > parsing a big string in smaller strings.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT