Re: How to get a newline
- From: "victorsk" <victorsk@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 7 Sep 2005 12:29:01 -0700
Hi,
Thanks so much for replying. This looks very promising, I didn't know about
this class. Thanks again, that should work.
Thank you,
Victor.
"CheckAbdoul" wrote:
> If the input is going to be a plain text file instead of a binary file,
> then use the CStdioFile MFC class to read the data. Something like
>
> CStdioFile layerFile;
> if ( layerFile.Open( TEXT("C:\\Data\\SVG\\Web\\layers.txt"),
> CFile::modeRead | CFile::typeText ) )
> {
> CString sLine;
> while ( layerFile.ReadString( sLine ) )
> {
> YourListBox.AddString ( sLine ) ;
> }
> layerFile.Close();
> }
>
> --
> Cheers
> Check Abdoul [VC++ MVP]
> -----------------------------------
>
>
> "victorsk" <victorsk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:87560AF0-4ECD-437C-AB4B-1439F27C3CD0@xxxxxxxxxxxxxxxx
> > Hello,
> >
> > I am working on a small procedure and it's giving me a headache. I have a
> > file that consists exactly of the following info:
> > Name1/
> > Name2/
> > Name3/
> >
> > I am trying to read each name into a string and display it in a lisbox.
> > Here is what I am doing:
> >
> > TRY
> > {
> > pFile = new CFile(_T("C:\\Data\\SVG\\Web\\layers.txt"),
> > CFile::modeRead | CFile::shareDenyNone);
> > char pbuf [1000];
> > UINT nBytesRead = pFile->Read(pbuf, sizeof(pbuf));
> > int z = 0;
> > int i = 0;
> > int count = 0;
> > CString layer;
> > //GET THE DELIMITER NUMBER
> > while (z < 1000)
> > {
> > if (pbuf[z] == '/')
> > {
> > count++;
> > }
> > z++;
> > }
> > //GO THROUGH NUMBER OF DELIMITERS
> > //TO APPEND TO STRING
> > for (int u = 0; u < count; u++)
> > {
> > while (pbuf[i] != '/')
> > {
> > layer += pbuf[i];
> > i++;
> > }
> > m_layer.AddString(layer);
> > }
> > }
> >
> > What I keep getting in my ListBox is this:
> > Name1
> > Name1
> > Name1
> > Obviously the output is wrong and I think what is happening is that my
> index
> > 'i' stops at the end of Name1 and then doesn't go to the next line so
> during
> > next iterations I keep getting the same name Name1.
> >
> > Could somebody please tell me how to move index to the newline please? I
> > tried "/n" or "\n" (not sure which one) but this didn't work. Is there a
> way
> > to move index to the newline in my code? Please, help.
> >
> > Thank you,
> > Victor.
> >
>
>
>
.
- References:
- How to get a newline
- From: victorsk
- Re: How to get a newline
- From: CheckAbdoul
- How to get a newline
- Prev by Date: Re: How to get a newline
- Next by Date: Re: How can I write directly to a CD from within my app in a standard format?
- Previous by thread: Re: How to get a newline
- Next by thread: XMLDOMDocument and the callback
- Index(es):