Assignment doesn't work but address of with the dereference operator does?
user10751 Published in September 21, 2018, 8:05 am
I've been playing around with C++ (just starting out), and I'm trying to make a program that needs a function to count the lines in C++. However, I've encountered weird behavior where normal assignment doesn't work, but assignment through address of, and then immediate dereference does. Like this:
For a little background, the file I'm reading is a 6 line file where each line is a 32 bit binary string (equal to zero). When I print out c (with cout << c) it prints out seemingly correctly. Also, I am aware that this may not be the optimal or correct way of doing read lines from a file, but unless this simply can not possibly work, I am more interested in the underlying mechanics of why this behavior is happening, and what I am doing wrong.
c++ file c++11 variables dereference
share|improve this question
asked Feb 13 at 21:54
closed as off-topic by StoryTeller, Drew Dormann, Neil Butterworth, Captain Giraffe, 1201ProgramAlarm Feb 13 at 22:30
This question appears to be off-topic. The users who voted to close gave this specific reason:
"This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – StoryTeller, Drew Dormann, Captain Giraffe, 1201ProgramAlarm
If this question can be reworded to fit the rules in the help center, please edit the question.