c

Open source portable/cross-platform video camera capture library

Hello, I like to know if there's a open-source, cross-platform library for capturing web-cam data. Any other suggestions are welcome in case such solutions are not available. I am looking for something similar to portaudio if possible but this is not absolutely mandatory. Also open-source & cross-platform projects falling into this cat...

How to print result to standard output?

char line[MAXBUF]; char *result; while((result = fgets(line, MAXBUF, fp)) != NULL) { printf(result); } The following code doesn't work fully. Does anyone know how to print result?? MAXBUF is defined to be 1024 and fp is just a file pointer to some file. What im suppose t...

What’s the correct way to build the SQLite FTS extension as a DLL?

What’s the recommended way to build the SQLite FTS3 extension as a Windows DLL? I’m having the following problem: fts3_tokenizer.obj : error LNK2005: sqlite3_api already defined in fts3.obj The macro SQLITE_EXTENSION_INIT1 is used in both fts3_tokenizer.c and fts3.c. It creates a global variable named sqlite3_api, and since this ...

Distribute a binary executable of a program built with OpenCV?

I created a program in C that uses OpenCV. In addition to distributing the source and make files, I would like to distribute a Win32 binary that will run when an end-user clicks on it. Presumably I would need an easy way for the user to install the OpenCV libraries. What is the best way to do this? Should I be looking into installers, ...

How do I prefetch a pointer in C, targeting AMD Opteron 6168?

I am writing a multi-threaded program in C where one core periodically grabs an item from the head of a linked list while other cores append items to the back of the list (using CAS magic for thread safety, someone else provided that for me). It appears that my program will run faster if the core taking an item from the head of the list...

Question about c pointers and * & operators

Let's say I have this line of code in a program: int * number=0; int mystery=&6[number]; Mistery is a number and I can use &5 or &4 obtaining other numbers. But what does the "&6[]" mean? Thanks! ...

wait command wont wait for child process to finish c cpp c++

I am trying to write a c++ program that creates a child process, runs a command and pipes the output back to the input of a command the parent is running. I have the parent execute the wait(NULL) or wait((void*)pid) command but it does not wait. here is the code: #include <string.h> #include <fstream> #include <iostream> #include <uni...

Strange Core Dump problem.

My this code is dumping core : int main(int argc,char *argv[]) { char *p = "onnm"; printf("%c\n",++*(p++)); return 0; } What might be the reason in printf line ? ...

Rotating bits of any integer in C

Pass a integer 2 to this function and then return a integer which is 4 x = 2; x = rotateInt('L', x, 1); (left shift the bits by 1) Example: 00000010 -> rotate left by 1 -> 00000100 but if I pass this: x = rotateInt('R', x, 3); it will return 64, 01000000 Here is the code, can someone correct the error... thanks int rotateInt...

Different ways to define constants in C/C++

How many different ways are there to define constants in C or C++? I am already aware of using the const keyword and the #define directive. I heard somewhere that there are two more ways to define constants, but I've never seen any others. Are there any others? ...

Using Electric Fence (libefence) just for a shared library

In order to diagnose a tricky memory corruption bug (memory is getting randomly overwritten) I thought about utilizing Electric Fence + some custom mprotect calls to ensure that the corrupted data structures are only writable when I want them to be written to (and I immediately get a SIGSEGV when they are attempted to be written to). Un...

Surprising pointers

I am surprised to see this code segment print the same address for all the three pointers. int main(int argc,char *argv[]) { int arr[3][3]; printf("%p\n%p\n%p\n",arr,*arr,arr[0]); return 0; } Why this is so ? ...

bit shifting in C

int x = 2; x = rotateInt('L', x, 1); // should return 4 x = rotateInt('R', x, 3); // should return 64 Here is the code, can someone check it and let me know what the error is? Compilation is successful, but it says Segmentation Fault when I execute it. int rotateInt(char direction, unsigned int x, int y) { int i; for(i = 0; i ...

xslt support in go

Dear fellow go enthusiasts, I would need xslt support in a go program. As far as I know there will be no xslt library in the the near future and currently there is no binding to a xslt library in go. What is the FASTEST library on linux or cross platform to do 1) xslt 1.0 transformation 2) xslt 2.0 transformation ...

trouble pipeline three commands "dmesg|sort|more" c++/c

I have successfully piped the output of one command into the input of another and then show the output of the second command to the screen. I want to do this with three successive commands. (actually eventually I want to do it with N commands passed into the program at run time. This is my attempt at pipelining three commands together....

Palindrome in C without pointers and recursion

I'm trying to determine if a phrase is a palindrome (a word that is the same from left to rigth) or not but i can't make it work. What's wrong?, i can't use pointers or recursion or string type variables #include <stdio.h> #include <string.h> int main() { int i,j = 0,length; char space = ' '; char phrase [80],phrase2[80],phrase3[...

using UNIX Pipeline with C

I am required to create 6 threads to perform a task (increment/decrement a number) concurrently until the integer becomes 0. I am supposed to be using only UNIX commands (Pipelines to be specific) and I can't get my head around how pipelines work, or how I can implement this program. This integer can be stored in a text file. I would r...

Token return values in ANTLR 3 C

I'm new to ANTLR, and I'm attempting to write a simple parser using C language target (antler3C). The grammar is simple enough that I'd like to have each rule return a value, eg: number returns [long value] : ( INT {$value = $INT.ivalue;} | HEX {$value = $HEX.hvalue;} ) ; HEX returns [long hvalue] : '0' 'x' ('0'..'9'|'a'.....

using ALSA api - sound does not start until buffer has filled

The application I'm using only plays sounds after enough sound has been generated. Say I click the mouse 10 times, with no sound, and then after those ten clicks I'll hear ten mouse click sounds (for example) The only way I've found to alleviate this problem is to set a very short buffer size, which I don't want to do. I've been trying...

Convert UTC to days, hours minutes etc in C

I have a a long which has the time in UTC format as a timestamp for some data, now I want to convert it to this format: month 1-12 Day 1-31 24 Hour format 0-23 minute 0-59 second 0-59 subsecond nanoseconds 0-999,999,999 now the nanoseconds can obviously be set to 0 as it doesnt need to be that accurate. What is the best method to do t...