How Do I Read Text File into Array using C++
Posted on 2009-07-09
Im really unfamiliar with C++ so need some help. Can someone post the exact code that will do the following;
I have a text file called "C:\\bob.txt"
It contains 256 rows of 3 digits (separated by a space). ie. the first 3 lines are
33 47 50
12 88 99
44 90 23
Each number contains a maximum of 3 digits.
Each row represents a colour in RGB format. ie 1st number is red, 2nd number is green, 3rd number is blue.
I want to read the text file into an array of Color. Something along the lines of;
Color myColorArray = new Color;
Then you would use a loop and add each line of 3 digits (representing a color) to the array. ie.
Color col = Color::FromArgb(r,g,b);
then add col to the array
So basically I need to read the text file and add each line that represents a color to an array of Color.
Can someone post the exact code that would do this?