Having learned Java and C++, I've learned the OO-way. I want to embark on a fairly ambitious project but I want to do it in C. I know how to break problems down into classes and how to turn them into class hierarchies. I know how to abstract functionality into abstract classes and interfaces. I'm even somewhat proficient at using polymor...
I have a faulty hard drive that works intermittently. After cold booting, I can access it for about 30-60 seconds, then the hard drive fails. I'm willing to write a software to backup this drive to a new and bigger disk. I can develop it under GNU/Linux or Windows, I don't care.
The problem is: I can only access the disk for some time, ...
I'm wondering about the best way to deploy R. Matlab has the "matlab compiler" (MCR). There has been discussion about something similar in the past for R that would compile R into C or C++. Does anyone have any experience with the R to C Compiler (RCC) that was developed by John Garvin at Rice?
I've looked into it, and it seems to be...
I am trying to find any RTSP streaming library for Python or C/C++.
If not is there any other solutions for real time streaming?
How much easy or difficult it is to implement RTSP in Python or C/C++ and where to get started?
...
How do you efficiently transpose a matrix? Are there libraries for this, or what algorithm would you use?
E.g.:
short src[W*H] = {
{1,2,3},
{4,5,6}
};
short dest[W*H];
rotate_90_clockwise(dest,src,W,H); //<-- magic in here, no need for in-place
//dest is now:
{
{4, 1},
{5, 2},
{6, 3}
};
(In my specific case its src arr...
I have this fantasy of becoming a really good C programmer, but I've found it very hard to find learning resources on tackling big C projects. I've learned C a few times (I forget the fundamentals, since I don't code big projects in C) from K&R, O'Reilly's Practical C, and A Book on C. However, none of these cover the existing Unix libra...
There is this macro offsetof in C/C++ which allows you to get the address offset of a member in a POD structure. For an example from the C FAQ:
struct foo {
int a;
int b;
};
struct foo;
/* Set the b member of foo indirectly */
*(int *)((char *)foo + offsetof(b)) = 0xDEADBEEF;
Now this just seems evil to me and I can't see many legi...
How can I make a function which returns an array? I tried this
const int WIDTH=11;
const int HEIGHT=11;
int main() {
char A[WIDTH][HEIGHT];
A=rand_grid(WIDTH,HEIGHT);
return 0;
}
// Initializes a random board.
char[][] rand_grid(int i, int k) {
char* A[i][k];
for(j=0;j<i;++j) {
for(l=0;l<k;++l) {
A[j][l]=ran(10);
...
Is C/C++ still used for web programming? What I mean by web programming is the typical CGI kind of applications which generates HTML on the fly.
My main question is geared towards finding a suitable framework/library for C/C++ based web programming.
What library/framework would you recommend for web programming with C/C++? I am not l...
Possible Duplicate:
In C arrays why is this true? a[5] == 5[a]
3["zdvnngfgnfg"];
...
I'm writing a small wrapper for a C library in Python with Ctypes, and I don't know if the structures allocated from Python will be automatically freed when they're out of scope.
Example:
from ctypes import *
mylib = cdll.LoadLibrary("mylib.so")
class MyPoint(Structure):
_fields_ = [("x", c_int), ("y", c_int)]
def foo():
p = ...
strncpy supposedly protects from buffer overflows. But if it prevents an overflow without null terminating, in all likelyhood a subsequent string operation is going to overflow. So to protect against this I find myself doing
strncpy( dest, src, LEN );
dest[LEN-1] = '\0';
man strncpy:
The strncpy() function is similar, e...
If I do something like this:
float a = 1.5f;
float b = a;
void func(float arg)
{
if (arg == 1.5f) printf("You are teh awresome!");
}
func(b);
Will the text print every time (and on every machine)?
EDIT
I mean, I'm not really sure if the value will pass through the FPU at some point even if I'm not doing any calculations, and if ...
I have the following structure:
struct hashItem {
char userid[8];
char name[30];
struct hashItem *next;
};
In the function below I take a char pointer (char array) argument that I wish to assign to the struct.
void insertItem(struct hashItem *htable[], char *userid, char *name)
{
int hcode = hashCode(userid);
stru...
We're doing a small benchmark of MySQL where we want to see how it performs for our data.
Part of that test is to see how it works when multiple concurrent threads hammers the server with various queries.
The MySQL documentation (5.0) isn't really clear about multi threaded clients. I should point out that I do link against the thread ...
I have a multi-threaded application, I'm using pthreads with the pthread_mutex_lock function. The only data I need to protect is in one data structure. Is it safe if I apply the lock only when I write to the data structure? Or should I apply the lock whenever I read or write?
I found a question similar to this, but it was for Windows...
Hi,
in the following piece of code:
.......
mystring ID;
char dum[]="_";
fprintf(fp_file,"%s%s%d ",ID,dum,1);
.....
ID is a string like "customers "
so I get the output:
"customers _1"
But my intention is to get
"customers_1"
For technical reasons I can not modify ID in any way, so I wonder how, when the program ...
Consider the following code.
int main(void) {
char * test = "abcdefghijklmnopqrstuvwxyz";
test[5] = 'x';
printf("%s\n", test);
return EXIT_SUCCESS;
}
In my opinion, this should print abcdexghij. However, it just terminates without printing anything.
int main(void) {
char * test = "abcdefghijklmnopqrstuvwxyz";
...
If i have a two programs named blah and ret.. I want to debug blah program which receives input from ret program via pipes .. how do I debug the blah program in the following case using gdb
bash> ret | blah
...
OK, I'm a bit confused here. The following code works:
HANDLE CreateSideThread()
{
DWORD dwGenericThread;
HANDLE hThread1 = CreateThread(NULL, 0, CallBackFunc, NULL, 0, &dwGenericThread);
return hThread1;
}
int main()
{
HANDLE Thread1;
Thread1 = CreateSideThread();
WaitForSingleObject(hThread1, INFINITE);
...