c

How can I build a Perl hash in C code?

I wish to embed a C code in Perl. In this C code I want to read a huge file into memory, make some changes and build a hash (a custom one). I wish to make this hash accessible from my Perl code. Is it possible? How can I reach the goal? ...

Permutation generator on C

I need a simple Algorithm of permutation generator which could be apply on simple C language. ...

how number of thread should be accepted via command line using pthread?

I am writting an application that has multiple threads in Linux environment using C or python. I am using pthread for that. But How number of threads should be accepted via command line. ...

An SSE Stdlib-esque Library?

Generally everything I come across 'on-the-net' with relation to SSE/MMX comes out as maths stuff for vectors and matracies. However, I'm looking for libraries of SSE optimized 'standard functions', like those provided by Agner Fog, or some of the SSE based string scanning algorithms in GCC. As a quick general rundown: these would be th...

Print ?? and !! in different sequence will show different output

I had found a strange output when I write the following lines in very simple way: Code: printf("LOL??!\n"); printf("LOL!!?\n"); Output: It happens even the code is compiled under both MBCS and UNICODE. The output varies on the sequence of "?" and "!"... Any idea? ...

Difference between char *str="STRING" and char str[] = "STRING" ?

Hello, While coding a simple function to remove a particular character from a string, I fell on this strange issue: void str_remove_chars( char *str, char to_remove) { if(str && to_remove) { char *ptr = str; char *cur = str; while(*ptr != '\0') { if(*ptr != to_remove) { ...

Creating static library from C++ code and linking with iPhone SDK

I have written some code in C++ with a corresponding C interface (i.e C-function wrappers around the classes) that a friend wants to use in an iPhone application. Since I heard you can compile C++ for the plattform, but not use the iPhone sdk at the same time (sic) I thought that compiling all the code into a static library that my frie...

ffmpeg (libavcodec) warning: encoded frame too large

Hi, I'm trying to use libavcodec (ffmpeg) to encode raw pixel data to mp4 format. Every thing goes well and I'm getting .avi file with decent quality but some times the codec gives "encoded frame too large" warning. And when ever it does that, a part of some frames (usually bottom portion of the frame) look garbled or all mixed up. Can ...

How do I printf() after a call to execlp() in a child process?

I am currently trying to print a message from a child process after calling execlp() within the child. However, nothing appears on the terminal after the call to execlp(). What causes my printf() calls to not display anything, and how can this be resolved? ...

Segmentation fault when call an static library function from OpenGL

I have simple OpenGL C program (from NeHe lesson 2). There is initialization function InitGL. And i have function foo in my static library: void foo(double *p) { p[0] = 1.0; } When i define array of double at start of InitGL: double arr[1000]; and modify it in InitGL all works fine. When i allocate memory for this array dynam...

Program without main()

Possible Duplicate: C program without main function ? Can we write a c program without main() which can run and execute? Please reply... ...

extern "C" (C linkage) by default

Question Do GCC, MSVC, or Clang, or some combination support setting linkage to default to C? Background I have a large mixed C/C++ project, and while it's easy and logical to export symbols in the C++ sources with C linkage, those same sources are assuming the stuff in the rest of the project are under C++ linkage. The current situa...

Conversion of fixed point signed Q8 to Q4 format

Hi I need to convert from fixed point signed Q8 format to fixed point signed Q4 format in c. I assume that I can just do a bitshift by four, is this correct? Do I need to take into account the sign bit? Update: This is for an ARM11 architecture, but I would prefer a non-architecture specific solution. Thanks ...

sizeof a struct member

Hello How can I get the size of a member in a struct in C? struct A { char arr[64]; }; i need something like that: sizeof(A::arr) thanks ...

What's wrong with these system calls?

I'm at a loss debugging this code. I copied the example from a guide, is this file being improperly indexed? #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> char *inicio(void); main(void) { char *c; int fd, sz, i; c = inicio(); fd ...

ldd command searching libs at some arbitrary location

I ran truss command on executable and get the below output: stat64("/net/xyzmachine/vol/tools/solx64/studio11/SUNWspro/lib/rw7/librt.so.1", 0x080474A0) (sleeping...) stat64("/net/xyzmachine/vol/tools/solx64/studio11/SUNWspro/lib/rw7/librt.so.1", 0x080474A0) Err#2 ENOENT stat64("/net/xyzmachine/vol/tools/solx64/studio11/SUNWspro/lib/libr...

Why the output of the following 3 programs is like this ?

#include<stdio.h> int add(int,int); int main() { int p=add(10,20); printf("%d",p); return 0; } int add(int x, int y) { int sum=x+y; } O/P: 30 #include<stdio.h> int add(int,int); int main() { int p=add(10,20); printf("%d",p); return 0; } int add(int x, int y) { int sum=x+y; printf("Hello"); } O/P: 5 #include<s...

What does a single vertical bar mean in C

Someone showed me the following code snippet and asked what it meant: if (!pFCT->FBMap(| ( VBQNum - 1 ) / 8 |) & (1 << (7 - ( ( VBQNum - 1 ) % 8))))) { stuff } And I got stuck on the stand alone vertical bars. I know two together mean "or" but just one, what does that mean. ...

Getting number of rows from SQLite C interface in Objective-C

Hi, I am new to objective-C and iphone apps. I am accessing SQLite and have 3 rows in my table "coffee". I used the following way to grab sth out from the table, however, only then 2nd and 3rd rows are being pulled out {the 1st row is always missed}. Is that due to the logic in my while loop by checking while sqlite3_step(selectstmt) r...

Pass character stream to libxml2

Hi, I have a XML document which is received as a character stream. I wish to parse this using libxml2. Well one way would be to save it as an .xml and then open it using one of the libxml2 API's. Is there a way i can directly build a tree on this stream and parse it ? Env is purely c++/c. Cheers! ...