Hi guys, could some one help me out trying to understand how hard drive seeking works.
I have a small binary database file which read performance is absolutely essential. If I need to skip a few bytes in the file is it quicker to use seek() or to read() then discard the unwanted data.
If the average seek time of a hard drive is 10ms an...
I want to implement the following have a character buffer and the code I am trying to port puts this character buffer in a stream and then does a get like this
char *buffer; //this is initialized
int bufferSize; //this is initlized
std::istringstream inputStream (std::string(buffer, bufferSize));
int getVal = inputStream.get();
E...
I have code like this, and I find it a bit hard to read:
// code1
if( (expensiveOperation1() && otherOperation() && foo())
|| (expensiveOperation2() && bar() && baz()) {
// do something
}
I just changed it to the following, to make it more readable:
// code2
const bool expr1 = expensiveOperation1() && otherOperation() && foo(...
I have a vector that I am loading with a know amount of elements (N).
The processing dynamically creates new elements, which are appended to the vector.
I am expecting about 2 * N additional elements to be created,
so I resize the vector to 3 * N.
If the additional elements exceed that, I would like a program abort, rather than ...
I notice on the same machine, it takes C# much less time than C++ to compile. Why?
NOTE1: I have not done any scientific benchmark.
NOTE2: Before anyone says this isn't programming related, I am implementing a parser, I am finding what I can do from the get go to increase compile speed.
NOTE3: I have a similar question http://stackov...
Hi everyone,
I'm working on a game and I'm currently working on the part that handles input. Three classes are involved here, there's the ProjectInstance class which starts the level and stuff, there's a GameController which will handle the input, and a PlayerEntity which will be influenced by the controls as determined by the GameContr...
I don't get why I get 0 when I use printf and %d to get the size of my vector:
vector<long long> sieve;
int size;
...
//add stuff to vector
...
size = sieve.size();
printf("printf sieve size: %d \n", size); //prints "printf sieve size: 0"
std::cout << "cout sieve size: ";
std::cout << size;
std::cout << " \n ";
//prints "cout sieve size...
Background
I have a container class which uses vector<std::string> internally. I have provided a method AddChar(std::string) to this wrapper class which does a *push_back()* to the internal vector. In my code, I have to add multiple items to the container some time. For that I have to use
container.AddChar("First");
container.AddChar(...
Hi,
I am working on a game using Visual C++. I have some components in separate projects, and have set the project dependencies. How do I #include a header file from a different project? I have no idea how to use classes from one project in another.
Thanks
...
Im trying to change the thread priority in boost but im having no luck. Im getting a bad handle error (type 6) from the GetLastError function. I though native_handle() returned the handle for the thread?
Any one know how to do this?
void baseThread::applyPriority(uint8 priority)
{
#ifdef WIN32
if (!m_pThread)
return;
BOO...
I have some existing code that I've used to write out an image to a bitmap file. One of the lines of code looks like this:
bfh.bfType='MB';
I think I probably copied that from somewhere. One of the other devs says to me "that doesn't look right, isn't it supposed to be 'BM'?" Anyway it does seem to work ok, but on code review it gets ...
I am asking about a good reference for multithreading programming in terms of concepts
with good examples using C++/C#?
...
I have Visual Studio 2008 SP1 Professional installed. I have built a C++ application and I want to install the redistributable runtime on another machine. Is the installer available in VS installation? Or do I have to download it?
...
Searched for a while, but I can't figure out why this would raise a bus error.
Any help would be much appreciated.
typedef struct {
set<int> pages;
} someStruct;
...
void someFunction() {
...
someStruct *a = createSomeStruct(); // just mallocs and returns
a->pages.insert(5);
...
}
...
Hello, I'm writing a server in C++ using Boost ASIO library. I'd like to get the string representation of client IP to be shown in my server's logs. Does anyone know how to do it?
...
Hello,
I've been trying to use CDT with Eclipse 3.4 under Windows XP with cygwin.
What do I need to do, in order to get startet?
I used "eclipse-cpp-ganymede-SR1-win32.zip" found on the Eclipse homepage.
Edit:
The main problem is, that I cannot compile and run the code.
In the run configuration, I tried gcc.exe for the C/C++ Applica...
Hi,
I am trying to play a compressed AVI file using MCI in C#. So far I was able to play it by opening the file.
The way I opened the file is this:
String opencommand = "open \"" + file + "\" type mpegvideo alias someMovie shareable";
int error;
error = Avi.mciSendString(opencommand, null, 0, IntPtr.Zero);
Where "file" is th...
I just got a new quad core computer and noticed that nmake is only using 1 process.
I used to use make which had the switch -j4 for launching 4 processes. What is the nmake equivalent?
[edit]
Based on the information below I have been able to add a command to my qmake project file:
QMAKE_CXXFLAGS += /MP
Which effectively did it for ...
We're developing in C++ under Linux and about to set up automated tests. We intend to use a testing framework like CppUnit oder CxxTest. We're using Ant to build the software and we will also use it to run the tests.
As some tests are going to involve database access, we are looking for a tool or framework which facilitates the tasks of...
Hi,
I want to know if there is a design pattern for specifying options to a set of algorithms. I am using C++.
Let me describe my problem. I am having a set of algorithms and these algorithms have different options. I want to design a single point access to these algorithms. Something similar to a strategy pattern. This single point acce...