Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #10312
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Best way to write the vector content to a file. |
| Date | 2011-09-20 15:12 +1200 |
| Message-ID | <9dqekjF76kU6@mid.individual.net> (permalink) |
| References | <31086262.1123.1316487944574.JavaMail.geo-discussion-forums@yqaa12> |
On 09/20/11 03:05 PM, sravanreddy001 wrote:
> Hi,
>
> Can anyone give the best way (faster) to write the vector contents to a file?
>
> Is there a better way to do it than below method?
>
> for(unsigned i=0;i<terms.size();i++){
> sprintf(temp,"%d %s\n",i,terms[i].c_str());
> ids_n_terms = ids_n_terms + temp;
> }
Where do you do the write?
> Is the string addition a very expensive operation? (will a new memory allocation takes place)
>
> there are around 5,00,000 (strings) in the vector, and these have to stored in
> <id term> format.
You will probably be I/O limited, so optimising your code won't make any
significant difference.
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:05 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 15:12 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:28 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 15:37 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:50 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 16:03 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:47 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 16:09 +1200
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-19 20:29 -0700
Re: Best way to write the vector content to a file. Juha Nieminen <nospam@thanks.invalid> - 2011-09-20 06:44 +0000
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 00:37 -0700
Re: Best way to write the vector content to a file. Ian Collins <ian-news@hotmail.com> - 2011-09-20 19:45 +1200
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 02:01 -0700
Re: Best way to write the vector content to a file. Rui Maciel <rui.maciel@gmail.com> - 2011-09-20 10:56 +0100
Re: Best way to write the vector content to a file. Fulvio Esposito <esposito.fulvio@gmail.com> - 2011-09-20 04:03 -0700
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-20 05:00 -0700
Re: Best way to write the vector content to a file. Goran <goran.pusic@gmail.com> - 2011-09-20 06:55 -0700
Re: Best way to write the vector content to a file. Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-20 13:39 -0500
Re: Best way to write the vector content to a file. sravanreddy001 <sravanreddy001@gmail.com> - 2011-09-20 17:50 -0700
csiph-web