Category : io

my problem is that my stream insertion operator function returns a string like "0x55d55d9a6eb0" when I try using it through cout instead of a multi line descriptive string which comes from the output << line, here’s the relevant code. For context, it’s a template class which has a stream insertion operator trying to print out ..

Read more

I wrote a program that calculates cylinder and rectangle areas with user inputs. But I want improve my code. When user enter a character instead of number, it should output an error message. So I wrote some extra code but it’s not working correctly. #include <iostream> #include <ctype.h> using namespace std; class area_cl { public: ..

Read more

For a particular question, I need to perform calculations on a floating number, round it off to 2 digits after the decimal place, and assign it to a variable for comparison purposes. I tried to find a solution to this but all I keep finding is how to print those rounded numbers (using printf or ..

Read more

I am trying to read this file that looks like this (gameboard with 6 rows, 7 columns), and want to store the last value in a variable int called nextMove. 0000000 0000000 0000000 0000000 0000000 0000000 1 I’m reading this input file with this code: ifstream f; f.open(input_file); int n; for (int i = 0; ..

Read more