I have some code in a library which has to internally work with wstring, that's all nice and fine. But it's called with a TCHAR string parameter, from both unicode and non-unicode projects, and I'm having trouble finding a neat conversion for both cases.
I see some ATL conversions and so on but can't see the right way, without defining ...
Hello all,
I want to perform I/O operation in c++. I want to store a pointer to fstream object and using that same fstream I want to read and write to that file. Is it possible without using two different objects i.e ifstream for reading and ofstream for writing.
...
What changes are needed when porting "setbuf" in VS2005 to VS2008?
I have to modify a project in VS2005 to VS2008 to be able to build it. Below is the line of code that needs to be compiled in VS2008.
std::ifstream In;
In.setbuf(FileBuffer, BUFFER_REGION_SIZE);
When I compile the above code in VS2008, I see the below error.
e...
I'm trying to make a game (using irrlicht engine with c++) where you can trap your enemy using boxes. But I just don't get how to detect what should be moved when a collision between the user and one or more boxes is detected. Another thing is that there will also be some objects called bricks which will be able to block movements.
Sinc...
I've been working on porting a legacy project from Visual Studio 6 to 2008. After jumping a few hurdles I now have the new project building and executing. However, I've noticed that the output from the two versions of the program are very slightly different, as though the floating-point calculations are not equivalent, despite the fact...
I need simple solution, without using MFC,ATL,AFX etc. Just like you would include only windows.h . I'm now talking about Windows solution.
My problem is that I want to be able set focus back on the view part of a window. My window for example consist of view part, title bar and menu bar. After you press alt, focus jumps to the menu bar...
/usr/include/c++/4.4/bits/ios_base.h: In member function ‘std::basic_ios >& std::basic_ios >::operator=(const std::basic_ios >&)’:
/usr/include/c++/4.4/bits/ios_base.h:793: error: ‘std::ios_base& std::ios_base::operator=(const std::ios_base&)’ is private
/usr/include/c++/4.4/iosfwd:47: error: within this context
/usr/include/c++...
I have a problem with what appears to be some sort of implicit casting to const when I use iterators. I'm not really sure which code is relevant (if I did I probably wouldn't be asking this question!) so I will try my best to illustrate my problem.
typedef set<SmallObject> Container; //not const
void LargeObject::someFunct...
I'm trying to use nmake to build the libfcg (http://www.fastcgi.com/), however I'm getting the following error:
..\include\fcgios.h(23) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
I have the Widows SDK installed and the Windows.h file is present in this directory:
C:\Program Files\Microsoft S...
I have three lines of code:
//int pi;
activation->structSize = sizeof(rmsActivationT);
int pi; //program wont compile with this here
every time I uncomment the second int pi and comment the first int pi I get this error: syntax error : missing ';' before 'type'. When i uncomment this first int pi and comment the second int pi, my c...
I'm just testing out some basic networking code written in Visual C++. I have a client app and a server app that don't do anything fancy, since I'm just testing - basically, the client sends ASCII-encoded strings to the server and the server sends it back all in caps.
Everything works fine when I run both programs on my computer, IF I s...
I always liked coding and programming but I never got to learn it in a structured way. It has mostly been self study. I learned QBASIC, VB and PL/SQL while I was in school. Not very comprehensively, just enough to write some small fancy programs. Wanted to graduate in Comp science but somehow ended up majoring in something else. I did so...
What is the the name of a good site for Windows programming in C++?
...
I ran into a interesting issue today. Check out this pseudo-code:
void Loop()
{
static int x = 1;
printf("%d", x);
x++;
}
void main(void)
{
while(true)
{
Loop();
}
}
Even though x is static, why doesn't this code just print "1" every time? I am reinitializing x to 1 on every iteration before I print it. ...
Hi Guys
I need to compile and run a c++ program from java. I am using
Process a = Runtime.getRuntime().exec ("g++ -g function.cpp -o function");
Process b = Runtime.getRuntime().exec ("./function");
the problem is that the output I get from the c++ program is not correct but If I compile and run it myself in the command line it works ...
Hello StackOverflowers,
With a friend, we had following problem recently. There was a base class:
class A {
public:
A() : foo(10) {}
virtual int getFoo() const { return foo; }
protected:
int foo;
};
A friend implemented a class deriving from the one above.
class B : public A {
public:
void process() { foo = 666; }
p...
I'm looking at the code for basic_string (that is bundled with g++ 4.2.1). The copy constructor makes use of a grab() function to "grab" a copy of a string (increment its reference-count):
_CharT* _M_grab( const _Alloc& __alloc1, const _Alloc& __alloc2 ) {
return (!_M_is_leaked() && __alloc1 == __alloc2) ? _M_refcopy() : _M_clone(__a...
Hello
Can I use openmp in C++ objects' constructors?
What will be done, when there will be a global static object with such constructor?
...
I'm using HtmlElement to get an HTML element by it's ID and trying to display this value and return it (as a String). The problem is that it sees it as an Object.
I have a webBrowser in the code with an HTML file that has:
<label id="Address" text="asdf"></label>
In my C++ header file I have
HtmlElement^ element = this->webBrows...
I am trying to compile the multiple_sources.cpp to compile on my computer. I am running Xubuntu Lucid Lynx fully updated.
It will compile without issue with g++ -c multiple_sources.cpp but when I try to link and make an exectuable with g++ multiple_sources.o I get:
multiple_sources.cpp:(.text+0x3d): undefined reference to `boost::progr...