c

Left Recursion in Grammar Results in Conflicts

Throughout a Bison grammar I am using right recursion, and I have read that left recursion is better because it doesn't have to build the whole stack first. However, when I try to switch to left recursion on any of them, I always end up with a lot of conflicts, and I am not seeing why. Can anyone show me a generic example of where usin...

is it possible pass a function as a parameter in c ?

Possible Duplicate: How do you pass a function as a parameter in C? is it possible pass a function as a parameter in c ? if yes how ? ...

how to print out each bit of a floating point number?

I am trying to print out each bit of a floating point number in c. I can be able to do it for integer with this: int bit_return(int a, int loc) // bit returned at location { int buf = a & 1<<loc; if (buf == 0) return 0; else return 1; } the compiler wouldn't compile if I replace int a with float a. Does anybody have ...

Dns protocol header

I want to encode DNS protocol header using C and create a UDP datagram. Lets say I have a query www.google.com. Can anyone suggest how to go about it? You can find the header format here - http://www.nersc.gov/~scottc/software/snort/dns%5Fhead.html ...

Difference between "system" and "exec" in Linux?

What is the difference between system and exec family commands? Especially i want to know which one of them creates child process to work? ...

STM hash library for C (glib?)

I'm looking for some C library that includes STM-style (Software Transactional Memory) hash maps, but I had no luck so far. It would be great if it was based on glib / gobject, but it's not that crucial. It also doesn't need proper transactions over many objects - single immutable hash support is all I really need. Must haves: immutable...

Recursion using C language

When I compile this program I only get the first capital letter but not the rest. Input: ABldjfdslkjfCK I only get 'A' that is it? #include <stdio.h> #include <string.h> FILE *fp; int main(void) { int size; char input[100]; // array size of 100 if (fp = fopen("message.txt","r")) // file exists { fge...

C/C++/Objective-C text recognition library

Does anyone know of any free/open-source text recognition libraries in C/C++/Objective-C? Basically something that can scan an image, and read out all of the plain text. ...

Inspect Bison's $$ variable with GDB

If I set a breakpoint in a Bison .y file, is there a way I can inspect the contents of $$ pseudo variable at that breakpoint? ...

Tokyo Tyrant transaction support

I've noticed that rufus-tokyo and other apis support transactions in Tokyo Tyrant. I couldn't find any mention of the transaction support in the TT docs (http://1978th.net/tokyotyrant/spex.html#clientprog) Is that transaction support simulated? Or is there a way to do a server-side transaction using the C api? ...

robust string reverse

Hi, I am trying to code a trival interview question of reversing a string. This is my code: #include <string.h> char* rev( char* str) { int i,j,l; l = strlen(str); for(i=0,j=l-1; i<l/2 ; i++, j--) { str[i] = (str[i] + str[j]); str[j] = str[i] - str[j]; str[j] = str[i] - str[j]; } re...

weird error when passing pthread_t to function

I have a C header file which defines the following function: void my_func(pthread_t tid); This is defined by another function: void my_func(pthread_t tid) { ... When I compile, it says: ****.h:2: error: expected specifier-qualifier-list before ‘pthread_t’ Any ideas what I'm doing wrong? ...

C return and comparation inline

Hi everyone, I'm just to figure out what does this method do, I know there must be a way to put this line by line, can you help me please? Thanks int conditional ( int n, EXPRESSION * * o ) { return (evaluateExpression( *o++ )? evaluateExpression( *o ) : evaluateExpression( *++o ) ); } UPDATE: This is the evaluateExpression Code ...

What is meant by 2D array support?

I read that Python does not actually support 2D arrays but rather an array of an array. I understand the array of an array thing but what does it mean by supporting 2D arrays? In C a 2D array is simply converted to a 1D array by doing some fancy math (Seen here). Are there languages that implement actual 2D arrays? Thanks for the hel...

C - Saving a Small File As a String

Hey guys...In C, I wish to read a file in my current working directory (nothing fancy), into a string. Later, I'd like to print that string out so I can do some work on it. I'm more used to Java, so I'm getting my chops on C and would love an explanation on how to do this! Thanks fellas... ...

Giving Command line arguments in Xcode in C program

I am solving my C assignment in Xcode and in that program i have to give command line arguments when running the program and for this i have to user terminal like this: ./a.out myfirstCommand mySecondCommand I was wondering if it possible to give these kind of commands within xcode instead of going to terminal. Thanks ...

How to generate random file name under Linux?

I want to make a small program which use local namespace socket and I will need to use temporary file name as address of the socket. So how to generate random file name under Linux? + I'm using the C programming language under Debian Linux. + Acoording to the GNU C Library Reference,tmpname is not safe.But the safe ones tmpfile and mks...

8 bit enum, in C

I have to store instuctions, commands that I will be receiving via serial. The commands will be 8 bits long. I'd like to use Enumerations to deal with them in my code. Only a enumeration corresponds to a ... on this platform I think a 16 bit integer. I need to preserve transparancy between command name, and its value. So as to avoid ha...

Performance of the c code

I'm using gcc for my c programmes. How can I check which method is faster (suppose that I write a code to swap two numbers and I rewrote the same code using bit operator), is there any tool in linux to check the time,performance and space? ...

Where is pow function defined and implemented in C?

I read that the pow(double, double) function is defined in "math.h" but I can't find its declaration. Does anybody know where this function declared? And where is it implemented in C? Reference: http://publications.gbdirect.co.uk/c%5Fbook/chapter9/maths%5Ffunctions.html ...