cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
reading data from a file into a array
reading data from a file into a array
Oct 30, 2011 at 11:02pm UTC
closed account (
17MDjE8b
)
i need someone to help explain how i would read 40 numbers from a file into the array in the order they are read in. Im not good with arrays however i do know how to read data from a file normally. please help
Oct 30, 2011 at 11:25pm UTC
codekiddy
(783)
you'll have to use while statement like so:
1
2
3
ifstream file(
"/file"
);
int
* arr[40], i = -1;
while
(file >> arr[++i]);
just make shore that size of the array is big enough!
Last edited on
Oct 30, 2011 at 11:26pm UTC
Topic archived. No new replies allowed.