Jul 1, 2011 at 1:22pm UTC
Hi ! I am trying to convert a printf statement code line to cout in a C++ code. It is:
printf(" %c | %c | %c ",matrix[t][0],matrix[t][1],matrix [t][2]);
I am using g++ compiler and i tried to write this:
cout << mat[t][0]," | ",mat[t][1]," | ",mat[t][2] <<endl;
but i got an error which said "invalid operands of types `char' and `<unknown type>' to binary `operator<<"
Thanks for the help and answers ! ^_^
Jul 1, 2011 at 1:25pm UTC
Replace your commas with <<s and you should be good to go, assuming you remembered to #include <iostream>
, and state that you're using std::cout;
and using std::endl;
. :)
-Albatross
Jul 1, 2011 at 1:30pm UTC
Thanks for the help ! And yes....i did write #include <iostream>
and using namespace std;
before the program starts. Thanks for the help again !