I'm getting some strange performance results here and I'm hoping someone on stackoverflow.com can shed some light on this!
My goal was a program that I could use to test whether large seek's were more expensive than small seek's...
First, I created two files by dd'ing /dev/zero to seperate files... One is 1 mb, the other is 9.8gb... Th...
When trying to monitor a directory using inotify on Linux, as we know, we get notified as soon as the file gets created (before the other process finish writing to it)
Is there an effective way to make sure that the file is not read before writing to it is complete by the other process?
We could potentially add a delayed read; but as w...
#include <errno.h>
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
errno; //<-----DEBUGGER "CXX0017: Error: symbol errno not found"
perror("Error:");
if (ferror(source)) //<--ferror = 32 but there is no string from perror?
{
//error handling
...
I am using fopen to write to a binary file and using the cstdio (stdio.h) library due to legacy code and it must be cross-platform compatible with Windows and Linux.
For the prototype, FILE * fopen ( const char * filename, const char * mode );, I am using const char * mode = "ab", which will append to a binary file. Writing operations ...
I'm looking for an efficient way to implement a serialization mechanism in C. I know it would be simple to just store the data in JSON, for example, and then reinitialize everything during the parsing.
But I'm wondering if it is possible (or worth it) to write something that will just take my struct (containing dynamically allocated da...
I'm quite new to programming "larger" applications. I have now written a command line application with a few thousand lines of code in Visual C++ 2010, which compiles and works fine. Most of the code is C-compliant (I think), however, I found it useful to use some C++ constructs here and there. E.g., sometimes I used new/delete instead o...
I am maintaining a server application written in C many years ago. It has very few unit tests (cxxtest) and I am thinking about developing more.
I read on the subject of unit testing C programs in the last days and tried a few things also. The right thing to do appears to be to include the .c file containing the function to test from m...
I switched from Visual Studio to Code::Blocks yesterday, and just had some strange compiler error messages.
I included windows.h and i can use all the API calls just fine, such as creating window classes and creating windows / buttons and stuff. But when I tried to send some keypresses with SendInput(), I got error messages on these two...
Hello guys,
I am new to C programming and I am having problems understanding common pitfalls and common usages of different library functions in C programming. Can some one point me to a good resource where I can learn subtleties in C programming. Also can some one point me to a good resource learn debugging tools like gdb.
Also I wa...
Possible Duplicate:
What is the point of function pointers?
can anyone explain what function pointers are and why they are needed in layman terms. In c context please?
...
I have an iPod touch and iPad with gcc installed on them. However, everytime I try to compile my programs they always fail. I am trying to write c programs for the terminal, not GUI. I am missing the standard c/c++ libraries (stdio.h, etc.). Can anyone tell me where I can find these libraries?
...
I'm in the planning stage of a relatively large (10k+ lines) project with several classes (30+) and several levels of class inheritance (5+).
What is the best (or most conventional) way to lay out my project in terms of file and folder structure?
Should I have one file per class? Should I have one folder per inheritance branch?
Should...
I'm making a vector drawing application. I use this algorithm to generate outlines.
This algorthm works well, except it does not close the outline as seen here:
I'm not sure what I should do to ensure that it always closes the outline. I tried inserting the last vertex at position[0] in the std::vector but this did not help.
DOUBLEPO...
I am trying to retrieve some values from the registry.
Here is the full path:
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes]
"ThemeChangesMousePointers"=0x00000001 (1)
And here is my code:
HKEY hKey;
DWORD dwDisp = REG_DWORD;
DWORD dwType;
DWORD dwSize = sizeof(DWORD);
DWORD dwValue = 0;
DWORD dwReturn;
char buffe...
One can use a CRITICAL_SECTION variable to get mutual exclusion.
My question is: does CRITICAL_SECTION support copying? If I pass one by value to another thread, can I know for sure that mutual exclusion will work?
I wouldn't be surprised if the answer is "you cannot do that", but it'd be nice to have some sort of official confirmati...
I use the following algorithm to generate polygon outlines:
void OGLSHAPE::GenerateLinePoly(std::vector<DOUBLEPOINT> &input, int width)
{
OutlineVec.clear();
if(input.size() < 2)
{
return;
}
if(connected)
{
input.push_back(input[0]);
input.push_back(input[1]);
}
float w = width...
Is there a way to redirect stdout with low level API... haven't found a function or a way to actually do this....
...
Lets say for example I have the following 2 vectors:
*B
*A
The vector I would want would be C
*C *B
*A
What I'm trying to do is generate square outlines. I use 2d slurp: where v0 would be A and v2 would be B. Right now I use sslerp2D to make round edges but I also want regular square edges hence why I want to...
I found this tutorial about ffmpeg the thing i do not get is how to encode video.
can any one, please provide a tutorial.. with explanations for that? (not that i dont get this official one but i'd love to see more comments)
...
What is the difference between this:
somefunction() {
...
char *output;
output = (char *) malloc((len * 2) + 1);
...
}
and this:
somefunction() {
...
char output[(len * 2) + 1];
...
}
When is one more appropriate than the other?
thanks all for your answers. here is a summary:
...