From: He Hongfu on
Hi,

I'd like to read string from a text file line by line. But wxFile or
wxFileInputStream only support read data from file byte by byte. How can
a read lines from a text file like the following?

while (reader.HasMore ()) {
wxString line = reader.ReadLine ();
// do something.
}

Thanks in advance.

He Hongfu


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Alvin Morris" on
uhm... something like this I think....

def lines(file):
for line in file: yield line
yield '\n'

?
I haven't tried it but it looks like it might work :D haha... or some
variation of it... ^_^;;
On 7/12/06, He Hongfu <hhfesle(a)sohu.com> wrote:
>
> Hi,
>
> I'd like to read string from a text file line by line. But wxFile or
> wxFileInputStream only support read data from file byte by byte. How can
> a read lines from a text file like the following?
>
> while (reader.HasMore ()) {
> wxString line = reader.ReadLine ();
> // do something.
> }
>
> Thanks in advance.
>
> He Hongfu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>


--
[adm]
From: Sergei Steshenko on


--- Alvin Morris <alvin.morris(a)gmail.com> wrote:

> uhm... something like this I think....
>
> def lines(file):
> for line in file: yield line
> yield '\n'
>
> ?
> I haven't tried it but it looks like it might work :D haha... or some
> variation of it... ^_^;;
> On 7/12/06, He Hongfu <hhfesle(a)sohu.com> wrote:
> >
> > Hi,
> >
> > I'd like to read string from a text file line by line. But wxFile or
> > wxFileInputStream only support read data from file byte by byte. How can
> > a read lines from a text file like the following?
> >
> > while (reader.HasMore ()) {
> > wxString line = reader.ReadLine ();
> > // do something.
> > }
> >
> > Thanks in advance.
> >
> > He Hongfu
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
> >
> >
>
>
> --
> [adm]
>

I am confused - the original question was in "C", and the answer is in
Python ? Or what language is that ?

Applications From Scratch: http://appsfromscratch.berlios.de/

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: "Alvin Morris" on
was the original question in C? I didn't notice the brackets! my
apologies....

On 7/12/06, Sergei Steshenko <sergstesh(a)yahoo.com> wrote:
>
>
>
> --- Alvin Morris <alvin.morris(a)gmail.com> wrote:
>
> > uhm... something like this I think....
> >
> > def lines(file):
> > for line in file: yield line
> > yield '\n'
> >
> > ?
> > I haven't tried it but it looks like it might work :D haha... or some
> > variation of it... ^_^;;
> > On 7/12/06, He Hongfu <hhfesle(a)sohu.com> wrote:
> > >
> > > Hi,
> > >
> > > I'd like to read string from a text file line by line. But wxFile or
> > > wxFileInputStream only support read data from file byte by byte. How
> can
> > > a read lines from a text file like the following?
> > >
> > > while (reader.HasMore ()) {
> > > wxString line = reader.ReadLine ();
> > > // do something.
> > > }
> > >
> > > Thanks in advance.
> > >
> > > He Hongfu
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> > > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
> > >
> > >
> >
> >
> > --
> > [adm]
> >
>
> I am confused - the original question was in "C", and the answer is in
> Python ? Or what language is that ?
>
> Applications From Scratch: http://appsfromscratch.berlios.de/
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>


--
[adm]
From: Zhao Dexiang on
Wrote like this:

ifstream ifs ("C:\\userinfo.dat", std::ios::in);

if(!ifs.is_open())
{
return;
}

// string line;
while(!ifs.eof())
{
char buf[1024] = {0};
ifs.getline(buf, sizeof(buf));
wxString cc(buf, wxConvLocal);
wxMessageBox (cc);
}

ifs.close();
===============================
Is this that you want?

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org