Hi I have question regarding cin and buffer.
I want to make a simple io program which takes integers.
Anyway I stumbled to a problem with buffer. Using MinGW in windows7 the following code will print out all four integers that I input. But when I switch to SunOS and compile it with G++ it will only print out the first integer. Is this a...
This is how I am planning to build my utilities for a project :
logdump dumps log results to file log. The results are appended to the existing results if the file is already there (like if a new file is created every month, the results are appended to the same file for that month).
extract reads the log result file to extract relevant...
I have been playing around with Template functions, and made a little logger program. I have been trying to split this into header / source file, but I keep getting linker errors. I know this is simple, but I cant figure it out.
Also I have some convince vars in the logger header, where would be the "proper" place for those? (logStart, ...
I know the .Net framework very well and know where to find things ie: StreamReader, StreamWriter, Graphics, etc, and I know Java has similar things. The syntax is different but quite similar to c++ which I have a lot of native c++ experience. Therefore, what would you recomend as a good starting point for tutorials and such. Thanks
...
Normally someone would just go and grab Boost's Function Output Iterator but I'm not allowed to use Boost at work. That said, I just want to use the copy function to traverse a collection, call a function on each item, take the output of that function, and finally push_back it onto another collection. I've written some code:
#include ...
Two, maybe trivial questions:
1. Why can not I beat the STD functions?
Really. I spent the last three days implementing something faster than std::sort, just for the sake of doing it. It is supposed to be an introsort, and I suspect it uses the single pivot version quicksort inside. Epic fail. Mine was at least twice as slow.
In my u...
I'm embedding Lua in a C++ application using Lua5.1 and I'm having an odd issue with luaL_newstate().
This works:
lua_State *L = NULL;
int main()
{
L = luaL_newstate();
return 0;
}
I recently restructured my code and chose to create an init function like this:
lua_State *L = NULL;
void init_lua(lua_State *L)
{
L = luaL_news...
Would it be quicker/efficient to write a file copy routine or should I just execute a System call to cp?
(The file system could differ [nfs, local, reiser, etc], however it would always be on a CentOS linux system)
...
I wanted to create a little macro to simulate for(auto item : container) in VC2010 which I can then replace with the real construct when it's released.
There is BOOST_FOREACH, however I would like auto support.
I've tried creating a macro. However it fails when the dereferenced iterator is a constant type.
#define _LIB_FOREACH_LINENAM...
Is it possible to generate a tree of function calls at runtime? I'd like to get a feel of what the program is calling.
This is essentially the same as breaking at a particular location, stepping through each function, and recording down what the function names are. I have no performance constraints.
I am using Visual Studio, but do not...
Is there a c++ framework for building rich desktop applications?
Essentially the important feature I'm looking for similar to Flex4 MXML to separate the visual presentation and application logic into xml. Does Qt4, for example, allow the visual appearance to be specified in xml definition? This is state based, so on events the UI change...
Hey Guys,
I just have a problem that I have been trying to fix for the longest time.
I have a static library project in visual c++, and I want another project to be able to link to it. Up until now, I have simply been adding a reference to the static library project, which automatically links the library.
I want to be able to link to ...
I'm utilizing a library written by a collegue and discovered that valgrind was spewing out errors related to the delete.
The problem was that there were allocations of char arrays like
char* s = new char[n];
followed up later with delete s
instead of delete[] s
He tells me that the difference is really that delete[] s will call a d...
I know and understand that global variables and magic numbers are things to avoid when programming, particularly as the amount of code in your project grows. I however can't think of a good way to go about avoiding both.
Say I have a pre-determined variable representing the screen width, and the value is needed in multiple files. I coul...
Take note of the following C++ code:
#include <iostream>
using std::cout;
int foo (const int);
int main ()
{
cout << foo(3);
}
int foo (int a)
{
a++;
return a;
}
Notice that the prototype of foo() takes a const int and that the definition takes an int. This compile without any errors...
Why are there no compilation errors...
I've got a class definition similar to the following:
class UUID
{
public:
// Using implicit copy assignment operator
private:
unsigned char buffer[16];
};
I've just had a unit test fail on me that was verifying that copy assignment worked properly. To my surprise, one byte in the middle of the buffer[] array was copied ...
I'm trying to write a fake vector for my class assignment, and I currently get an error in the member function pushBack.
The compiler doesn't seem to like incrementing the SIZE variable which holds the number of elements in the "vector". Is there something I might need to fix?
Your assistance would be highly appreciated for helping me wi...
Apologies for the vast scope of question. But what is the design factor in managing memory in C++?
For example: why is there a memory leak when a program does not release a memory object before it exits? Isn't a good programming language design supposed to maintain a "foo-table" that takes care of this situation ? I know I am being a bi...
Hello!
Does someone know any C++ library / interface to handle 3d-model data in common formats (.obj, .3ds, .ply, ...)?
There are some libraries that I can find, like lib3ds or libobj, but if
I want to handle different object formats, I would really need to get used to API of them all and write a bunch of my own wrappers so that my co...
Let's say I have three object A, B, C.
B is the implementation of following interface:
interface D
{
event EventHandler<OrderEventArgs> OrderCreated;
event EventHandler<OrderEventArgs> OrderShipped;
}
I would add two functions in B which will raise the events in the interface.
class B
{
RaiseOrderCreated();
RaiseOrderSh...