I have a bug in a multi-processes program. The program receives input and instantly produces output, no network involved, and it doesn't have any time references.
What makes the cause of this bug hard to track down is that it only happens sometimes.
If I constantly run it, it produces both correct and incorrect output, with no discerni...
I'm trying to figure this part of C out. I've read some tutorials given to me but I haven't found it yet.
Trying to read libraries I see that there are .c and .h files of the same name. In the main sourcethe .h file is included but not the .c file. When I look at the code in the .h file it also doesn't #include the .c file of the sam...
I've been enamoured with component based programming (be it with COM, another system, or just using the paradigm in plain C++). It requires a bit of getting used to, if one is usually used to the "traditional" OOP model, but it's definetely worth it. It's made my code more maintainable and easier to extend.
The project I'm currently wo...
glCallLists() is a convenient function for rendering a series of display lists, especially for things like text rendering. I'm curious -- is it actually more efficient to call glCallLists(), or is it merely a convenience function? For example, which of these two snippets is likely to be faster?
const char *str = "this is a test";
// s...
When to use the assembly to debug a c/c++ program?
Does it help to learn some assembly to debug programs?
...
Let me first say that I've got a fair amount of experience in both C and C++. However, I'm starting a new project in C and I've been working in object-oriented languages for so long (C# and C++) that I am having trouble coming up with an effective way to encapsulate functionality in a procedural language. My first thought was to simply...
Below is my C wrapper for a Fortran ZHEEVR routine from well-known LAPACK numerical library:
void zheevr(char jobz, char range, char uplo, int n, doublecomplex* a, int lda, double vl, double vu, int il, int iu, double abstol, double* w, doublecomplex* z, int ldz, int* info)
{
int m;
int lwork = -1;
int liwork = -1;
int l...
I'm trying to write a program that uses fattach but the compiler says fattach not implemented. I have included the header file stropts.h. what should I do?
...
For my bachelor thesis i want to visualize the data remanence of memory and how it persists after rebooting a system.
I had the simple idea to mmap a picture to memory, shut down my computer, wait x seconds, boot the computer and see if the picture is still there.
int mmap_lena(void)
{
FILE *fd = NULL;
size_t lena_size;
vo...
What do you do when you have a set of .h files that has fallen victim to the classic 'gordian knot' situation, where to #include one .h means you end up including almost the entire lot? Prevention is clearly the best medicine, but what do you do when this has happened before the vendor (!) has shipped the library?
Here's an extension ...
Considering this code, VC9 doesn't detect aliasing :
typedef struct { int x, y; } vec_t;
void rotate_cw(vec_t const *from,
vec_t *to)
{
/* Notice x depends on y and vice versa */
to->x = from->y;
to->y = -from->x;
}
/* ... */
vec_t a, b;
rotate_cw(&a, &b); /* OK, no aliasing */
rotate_cw(&a...
Currently I am working with Java and its object oriented-design aspects (I also work with PHP/MySQL a lot). I don't implement it on the web; I just use it for designing programs for general purposes. However, now I need to learn C right now, and I have an interest in C++. I got The C Programming Language, which some people say is the bes...
We have an application written in C language which interacts with Oracle database. This application is an executable and runs on unix platform. We need to expose this application over http as web service for others to consume.
I thought of using JNI and CXF for webservice and run the application in tomcat.
Is this a right solution or t...
My application has potentially a huge number of arguments passed in and I want to avoid the memory of hit duplicating the arguments into a filtered list. I would like to filter them in place but I am pretty sure that messing with argv array itself, or any of the data it points to, is probably not advisable. Any suggestions?
...
I really have no idea why this is happening...
I created a win32 application in emacs, and whenever I make it and run it (not through the command prompt), a command prompt window pops up under the window. If I build a win32 application in Code::Blocks, and just run its default template, then it runs without a command prompt window. I loo...
I am currently writing a fast 32.32 fixed-point math library. I succeeded at making adding, subtraction and multiplication work correctly, but I am quite stuck at division.
A little reminder for those who can't remember: a 32.32 fixed-point number is a number having 32 bits of integer part and 32 bits of fractional part.
The best algor...
I want to do the following
char a[] = { 'A', 'B', 'C', 'D'};
But I do not want to write these characters separately. I want something like
#define S "ABCD"
char a[] = { S[0], S[1], S[2], S[3] };
But this won't compile (gcc says 'initializer element is not constant').
I tried replacing the #define line with
const char S[] = "ABCD...
In C, C++ and C# when using a condition inside a function or loop statement it's possible to use a continue or return statement as early as possible and get rid of the else branch of an if-else statement. For example:
while( loopCondition ) {
if( innerCondition ) {
//do some stuff
} else {
//do other stuff
}
...
Hi
I'm new to C and i can't compile a program i downloaded.
The Errormessage looks like this :
********@*******:~/Desktop/GRAPPA20$ gcc all_sorting_reversals.c
/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/crt1.o: In function `_start':
/build/buildd/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
/tm...
I have a large number of instances of a C structure like this:
struct mystruct
{
/* ... */
unsigned flag: 1;
/* ... */
};
flag is initially 0 but must be 1 on exit from a certain function.
The simplest implementation is:
void set_flag(struct mystruct *sp)
{
sp->flag = 1U;
}
But what is the likely effect on perfor...