c

'RTLD_NEXT' undeclared

I'm trying to compile a C program but I get the error 'RTLD_NEXT' undeclared. I think this is supposed to be defined in dlfcn.h which the c program includes, but when I looked inside dlfcn.h there is no RTLD_NEXT. How do I fix this? ...

Best stats library for C (not C++)

Anyone know of a good statistics library for C? I'm looking for something that is commonly used and not a small project. EDIT: must be free! ...

How to make this C program compile?

When I type gcc gprof-helper.c to compile the program I get these errors: gprof-helper.c: In function `wooinit': gprof-helper.c:38: error: `RTLD_NEXT' undeclared (first use in this function) gprof-helper.c:38: error: (Each undeclared identifier is reported only once gprof-helper.c:38: error: for each function it appears in.) This is t...

How to cast a pointer to an int in c ( to get its ascii value )

I have a pointer ( *ascii ) which a pointer to a char and I want it is value as an int in order to make it an if statement like if ( ascii == 32 || ((ascii > 96) && (ascii < 123)) { } This is not working, i would appreciate help ...

How to modify a C program so that gprof can profile it?

When I run gprof on my C program it says no time accumulated for my program and shows 0 time for all function calls. However it does count the function calls. How do I modify my program so that gprof will be able to count how much time something takes to run? ...

Number of Zeros in the binary representation of an Integer

Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit integer? Given a 32-bit integer N,Devise an algorithm to find the number of zeros in the binary bit representation of N. The simplest algorithm I can think of is to check the binary representation for Zeros,in C something like this: int num_of_zero(...

How to insert an element into an array on malloc?

say we are going to insert an element into an array on malloc. I know where and how to insert, but I'm having trouble shuffling every succeeding element down by 1. What would be the technical approach for this? Thanks | x x x x x x x x x x x | original array | x x x x x 0 x x x x x x | new array Suppose the "memmove" function is not ...

Redirecting Command-line Arguments for Bootstrapping

I am trying to rewrite the following program in C instead of C# (which is less portable). It is obvious that "int system ( const char * command )" will be necessary to complete the program. Starting it with "int main ( int argc, char * argv[] )" will allow getting the command-line arguments, but there is still a problem that is difficult...

C Programming: address of a label

I know everyone hates gotos. In my code, for reasons I have considered and am comfortable with, they provide an effective solution (ie I'm not looking for "don't do that" as an answer, I understand your reservations, and understand why I am using them anyway). So far they have been fantastic, but I want to expand the functionality in s...

String Comparisons - C

Hello all. I'm trying to write a string routine in C, and I keep hitting on the same issue. In C, I have this string: MAMAAMAAALJ If I have this string: AAA How can I determine that AAA is inside of MAMAAMAAAJ? ...

how can I integrate the existing project written in C with the iphone view-based application project?

I would like to ask that if I have a project written in C and another project of view-based iphone application. How can I access that C methods, properties from the C library while I am working in the iphone project, I mean, how can I use the C project in iphone app? Any help would be appreciated, Thanks. ...

import CSV into SQLite WITHOUT a table schema

I know that I can import .csv file into a pre-existing table in a sqlite database through: .import filename.csv tablename However, is there such method/library that can automatically create the table (and its schema), so that I don't have to manually define: column1 = string, column2 = int ....etc. Or, maybe we can import everything ...

C unsigned int array and bit shifts

If i have an array of short unsigned ints. Would shifting array[k+1] left by 8 bits, put 8 bits into the lower half of array[k+1]? Or do they simply drop off as they have gone outside of the allocated space for the element? ...

How many GCC optimization levels are there?

How many GCC optimization levels are there? I tried gcc -O1, gcc -O2, gcc -O3, and gcc -O4 If I use a really large number, it won't work. However, I have tried gcc -O100 and it compiled. How many optimization levels are there? ...

How to get gcc -O1 optimization without specifying -O1

I know that -O1 automatically turns on certain flags. These flags can be turned on manually though. If I don't specify -O1, it should still be possible to get -O1 optimization by specifying all the flags that -O1 turns on. I tried -fthread-jumps -fcprop-registers -fguess-branch-probability but it still does not do -O1 optimization....

read() function in socket programming in c

I use this code for reading from socket : int n ; char buffer[256]; n = read(newsockfd, buffer, 255); if (n < 0) { error("ERROR reading from socket"); } if the data that must be read bigger than 255 byte (for example 1000) which change must be occured ? I know change char buffer[1000], I need different solution ....

Long Double in C

I've been reading the C Primer Plus book and got to this example #include <stdio.h> int main(void) { float aboat = 32000.0; double abet = 2.14e9; long double dip = 5.32e-5; printf("%f can be written %e\n", aboat, aboat); printf("%f can be written %e\n", abet, abet); printf("%f can be written %e\n", dip, dip); ...

How do I implement exceptions with nestable try-catch-finally statement with messages in C

I'm looking to implement exceptions with nestable try-catch-finally statement with messages in C using longjmp/setjmp. I've managed to implement try-catch-else exceptions, they are not nestable. I'm also hoping to add messages to the exceptions. Any idea how I might be able to do it? ...

Traverse Matrix in Diagonal strips

I thought this problem had a trivial solution, couple of for loops and some fancy counters, but apparently it is rather more complicated. So my question is, how would you write (in C) a function traversal of a square matrix in diagonal strips. Example: 1 2 3 4 5 6 7 8 9 Would have to be traversed in the following order: [1],[...

Weird result printing pointers as float in C

I know this is wrong and gcc will give you a warning about it, but why does it work (i.e. the numbers are printed correctly, with some rounding difference)? int main() { float *f = (float*) malloc(sizeof(float)); *f = 123.456; printf("%f\n", *f); printf("%f\n", f); return 0; } Edit: Yes, I'm using gcc with a 32-bit mach...