c

Where can I get these header files?

I'm attempting to compile SndObj, and I need some header files. Which Debian packages do I need to obtain all the missing header files? Checking for C header file alsa/asoundlib.h... (cached) no Checking for C header file soundcard.h... (cached) no Checking for C header file jack/jack.h... (cached) no Checking for C header file m_pd.h.....

Is `errno` thread-safe?

In errno.h, this variable is declared as extern int errno; so my question is, is it safe to check errno value after some calls or use perror() in multi-threaded code. Is this a thread safe variable? If not, then whats the alternative ? I am using linux with gcc on x86 architecture. ...

Validate max integer in scanf

I want to read a int from stdin but I want to validate if the user exceeds the int max value. How can I do it? int n; scanf("%d", &n); scanf reads the decimal input and stores in the int, causing overflow. How can I check and avoid this? ...

Implementing a Priority queue with a Conditional Variable in C

My current understanding of conditional variables is that all blocked (waiting) threads are inserted into a basic FIFO queue, the first item of which is awakened when signal() is called. Is there any way to modify this queue (or create a new structure) to perform as a priority queue instead? I've been thinking about it for a while, but...

Floating point again

Yesterday I asked a floating point question, and I have another one. I am doing some computations where I use the results of the math.h (C language) sine, cosine and tangent functions. One of the developers muttered that you have to be careful of the return values of these functions and I should not make assumptions on the return values...

How to make window application in ANSI C?

Hello, Until now I've been only writing console applications but I need to write a simple window application for a school assignment. Could somebody point me to a good tutorial how to create windows and other ordinary windows elements such as buttons, 2d graphs ect in ANSI C? is there some good library I should use? I tried googling b...

Translate a FOR to assembler

Hi everyone, I need to translate what is commented within the method, to assembler. I have a roughly idea, but can't. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, EXPRESION * * o ) { int a, i; //--- Translate from here ... for ( i = 0; i < n; i++ ){ a = evaluarExpresion( *o ); o++; ...

Problem with piping commands in C

Hi, I'm trying to create a simple shell in C for Unix. I've been able to do all the parsing of commands and execution, but I'm having a problem with piping. I think the problem is that I'm not hooking into the correct pipe for the input of the second command. For example, if I type "ls | wc", it will pause after the "wc" command, which...

Random float number help

I wrote this function to get a pseudo random float between 0 .. 1 inclusive: float randomFloat() { float r = (float)rand()/(float)RAND_MAX; return r; } However, it is always returning 0.563585. The same number no matter how many times I run my console application. EDIT: Here is my entire aplication if needed: #include <...

Hash/key creation function for latitude longitude?

Hello, I have blocks of data associated with latitude/longitude values. I'd like to create a lookup key/hash value from the latitude/longitude value so it can be used as a lookup into a map or something similar. I'm using negative values for West and South... therefore 5W, 10S is represented as -5, -10 in the program. I'd like to...

How to return this data in C?

This is a thought problem, and one I have been wrestling with for about a day. I am writing an engine for a game in C (open source, for fun), and all of the interface (read GUI) elements deal with mouse input in a function interfaceMouse(). Basically, I call interfaceMouse() on a regular basis to see if the user has acted with the inter...

Thread-safe, lock-free increment function?

UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function available in C or C++ ? ...

Where can I download gd.h?

I'm using Dev C++ to write a simple C program and I need to create an image. I know how to use GD but unfortunately it's not included in Dev C++ installation. Where can I download gd.h file? I'm using Windows Vista. ...

Multiple threads in C program

I'm writing a Unix application in C which uses multiple threads of control. I'm having a problem with the main function terminating before the thread it has spawned have a change to finish their work. How do I prevent this from happening. I suspect I need to use the pthread_join primitive, but I'm not sure how. Thanks! ...

How can I improve my C coding process on OS X?

Hi, I'm currently learning C from some Harvard screencasts. They're great. I'm currently, because I'm used to it, using this process for running my code: Type it it TextMate Save it gcc filname run "./a.out" goto 1 Is there a major process, program, or best practice I'm missing here? I've tried apple-R in TextMate, but to compile so...

Lineary separate two sets

I have three arrays (it's written in C but that is not important, it could be any language): float x[] = { 0.72, 0.91, 0.46, 0.03, 0.12, 0.96, 0.79, 0.46, 0.66, 0.72, 0.35, -0.16, -0.04, -0.11, 0.31, 0.00, -0.43, 0.57, -0.47, -0.72, -0.57, -0.25, 0.47, -0.12, -0.58, -0.48, -0.79, -0.42, -0.76, -0.77 }; flo...

What do .c and .h file extensions mean to C?

It's all in the title; super-simple I reckon, but it's so hard to search for syntactical things like things anywhere. These are two library files I'm copying from the web, and I'm wondering why they're called two different names From here: CS50.net ...

Multi-threaded debugging tutorial for GDB and C

Does anybody know of a good GDB (or other Linux debugger) tutorial for debugging multi-threaded C code? I'm looking for one that includes simple examples. ...

Simple Increment in assembler

Hi, I'm stuck with this. I'm self studying assenbler and translating some basics instructions. But i can't with this one. Can anyone help me, please? int secuencia ( int n, EXPRESION * * o ) { int a, i; for ( i = 0; i < n; i++ ){ a = evaluarExpresion( *o ); // Im trying to do this: o++; __asm { mov eax,dword ptr [...

Pointers to Structures in C

When trying to compile the following code, I am getting a warning that line 18 makes integer from pointer without cast and that 19 and 20 are incompatible types in assignment. I am new to structures in C, and can't seem to figure out what is wrong. #include <stdio.h> struct song { char title[70]; }; struct playlist { stru...