Hi everyone, i was hoping i could find some help here.
I am trying to get settings i have written into a textfile to be put in an array.
Here is what is in the txt file:

8
44100
1
2
1

I read the textfile with:

pStream = new FileStream(strSavePath, FileMode::Open);
pReader = new StreamReader(pStream);
count = 0;
for(;;)
{
count++
strLine = pReader->ReadLine();
Console::WriteLine(strLine);
if(strLine == 0)
break;
}

Now i want the strings i read from the txt file to be put into an array, with each new line being a new index of the array.
Thanks in advance.

Hi Greenthumb,

You can try this:

pStream = new FileStream(strSavePath, FileMode::Open);
pReader = new StreamReader(pStream);
count = 0;
int array[100];
for(;;)
{
    strLine = pReader->ReadLine();
    Console::WriteLine(strLine);
    if(strLine == 0)
        break;
    array[++count] = atoi(strLine);
}

Thanks, i got it to work now :D.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.