| | |
Getting an array from a txt file
Thread Solved |
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: May 2005
Posts: 48
Reputation:
Solved Threads: 3
Hi Greenthumb,
You can try this:
You can try this:
C Syntax (Toggle Plain Text)
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); }
![]() |
Similar Threads
- Setting an array and reading in a txt file backwards (C++)
- parse a .txt file (Java)
- 2D-Array, switches, and importing from a file (C++)
- reading txt file into array (C++)
- How can I read from a txt file? (C++)
- URGENT - Reading from txt file into a 2 dimension array (Java)
Other Threads in the C Forum
- Previous Thread: Dynamic Allocation is Other Scopes
- Next Thread: makes pointer from integer without a cast
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. lowest match matrix microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance pointer posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h





. 