2017-06-02 15:47 GMT+04:00 bob by <[email protected]>
> Can somebody here write a replacement for the standard cout, that will be
> able to print strings and integers, and internally will just redirect to
> puts and itoa? I'm only starting with C++, I'm not sure how to do it.
>
So, I'm trying to do this, This code seems to more or less work, but adding
#include <string> causes compile error at the HANDLE. Error says
"declaration of _imp__iob as array of references".
I kind of want to try out std::string, even though I don't know how it's
different from char*.
#include <windows.h>
class cout_c
{
public:
HANDLE stdout;
void init()
{
stdout = GetStdHandle(STD_OUTPUT_HANDLE);
}
cout_c& operator<<(char* s)
{
WriteFile(stdout, s, strlen(s), NULL, NULL);
return *this;
}
};
cout_c cout;
int main()
{
cout.init();
cout << "1234567890";
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public