Hello everyone,

I'm newbie with c++. I need to ask you probably a very simple question.
When I write a file with numbers from an array I then read in a file something like:
7
8
9
10
11
12

When I then read this file and print on screen I get:
7
8
9
a
b
c

Why is that? And how can I read these number in decimal format. I have to do operations after so I need them like int's.
Thanks for help in advance.

Recommended Answers

All 2 Replies

post code, I can't see your monitor from where I am setting.

I cant say for sure, but read them as ints;

int val = 0;
while(file >> val){
 cout << val << endl;
}
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.