R
Richard Lionheart
Hi All,
I'm running Visual Studio .Net, but I couldn't see how to build a ver.
6.0-style VC++ style program, so I'm using it to write a .cpp file and
then using the command-line compile/link instruction.
I copied a program of Josuttis from his web site, plugged it into my
little structure and got one diagnostic:
UpdatePresentersData.cpp(29) : error C2664:
'std::basic_ostream<_Elem,_Traits>::basic_ostream(std::basic_streambuf<_Elem
,_Traits> *,bool)' : cannot convert parameter 1 from 'const char *' to
'std::basic_streambuf<_Elem,_Traits> *'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
and
[
_Elem=char,
_Traits=std::char_traits<char>
]
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
The offending line, #29, is flagged in the code below. I'd appreciate
any suggestion on how handle this problem.
Thanks in advance,
Richard
#include <string> // for strings
#include <iostream> // for I/O
#include <fstream> // for file I/O
#include <iomanip> // for setw()
#include <cstdlib> // for exit()
using namespace std;
// Complile and link with:
// cl UpdatePresentersData.cpp /EHsc
// In SciTE, use [Shift] F6 to switch buffers.
// Forward declarations
void writeCharsetToFile(const string& sFilename);
void outputFile(const string& sFilename);
int main() {
std::cout << "Starting UpdatePresentersData" << std::endl;
writeCharsetToFile("charset.out");
outputFile("charset.out");
std::cout << "Press ENTER to close this window" << std::endl;
char c = getchar();
}
void writeCharsetToFile(const string& sFilename)
{
// Open output file
ostream file(sFilename.c_str()); // <<<< Line 29
// ^^^^^^^^^^^^^^ Line 29 ^^^^^^^^^
// File opened?
if (! file)
{
// No! Abort program
cerr << "Can't open output file \"" << sFilename << "\"" << endl;
exit (EXIT_FAILURE);
}
// Write character set
for (int i=32; i<256; i++)
{
file << "value: " << setw(3) << i << " "
<< "char: " << static_cast<char>(i) << endl;
}
}
void outputFile(const string& sFilename)
{
}
I'm running Visual Studio .Net, but I couldn't see how to build a ver.
6.0-style VC++ style program, so I'm using it to write a .cpp file and
then using the command-line compile/link instruction.
I copied a program of Josuttis from his web site, plugged it into my
little structure and got one diagnostic:
UpdatePresentersData.cpp(29) : error C2664:
'std::basic_ostream<_Elem,_Traits>::basic_ostream(std::basic_streambuf<_Elem
,_Traits> *,bool)' : cannot convert parameter 1 from 'const char *' to
'std::basic_streambuf<_Elem,_Traits> *'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
and
[
_Elem=char,
_Traits=std::char_traits<char>
]
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
The offending line, #29, is flagged in the code below. I'd appreciate
any suggestion on how handle this problem.
Thanks in advance,
Richard
#include <string> // for strings
#include <iostream> // for I/O
#include <fstream> // for file I/O
#include <iomanip> // for setw()
#include <cstdlib> // for exit()
using namespace std;
// Complile and link with:
// cl UpdatePresentersData.cpp /EHsc
// In SciTE, use [Shift] F6 to switch buffers.
// Forward declarations
void writeCharsetToFile(const string& sFilename);
void outputFile(const string& sFilename);
int main() {
std::cout << "Starting UpdatePresentersData" << std::endl;
writeCharsetToFile("charset.out");
outputFile("charset.out");
std::cout << "Press ENTER to close this window" << std::endl;
char c = getchar();
}
void writeCharsetToFile(const string& sFilename)
{
// Open output file
ostream file(sFilename.c_str()); // <<<< Line 29
// ^^^^^^^^^^^^^^ Line 29 ^^^^^^^^^
// File opened?
if (! file)
{
// No! Abort program
cerr << "Can't open output file \"" << sFilename << "\"" << endl;
exit (EXIT_FAILURE);
}
// Write character set
for (int i=32; i<256; i++)
{
file << "value: " << setw(3) << i << " "
<< "char: " << static_cast<char>(i) << endl;
}
}
void outputFile(const string& sFilename)
{
}