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 != '/')
{
layer += pbuf;
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.
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 != '/')
{
layer += pbuf;
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.