c

How to use the given FFT function in C?

Sorry this is the first time for me to ask question here, I've given a FFT function void fft_1d(int n, float xr[256], float xi[256], int ntype) { /* compute the FFT of a complex signal xr and xi are the real and imaginary parts respectively xr and xi contain the signal as input and the FT as output n is the number of po...

Chatbot library

I'm trying to add some simple chatbot behavior to an existing C program. The chat bot doesn't have to be too sophisticated (Eliza level) but it needs to have been written with reuse in mind. Are there any existing chat bot libraries available for C? ...

Printing directly to Ethernet printer using 'raster mode': need basic guidance

I've stumbled across a problem way beyond my area of expertise, and I don't have a mentor to turn to for help with this. I have a receipt printer I need to interface with through an iOS app. The printer is located on the same network as the device(s), so I can address it through supported "Line Mode commands" What I'd like to do is kee...

how to handle optimizations in code

I am currently writing various optimizations for some code. Each of theses optimizations has a big impact on the code efficiency (hopefully) but also on the source code. However I want to keep the possibility to enable and disable any of them for benchmarking purpose. I traditionally use the #ifdef OPTIM_X_ENABLE/#else/#endif method, b...

TextMate: Setting TM_C_FLAGS variable in the comments at the top of the C source file

How can I set the TM_C_FLAGS variable in the comments at the top of the C source file? I know I can set TM_C_FLAGS under Preferences → Advanced → Shell Variables, but I would like to set this variable separately for a C source file. ...

Casting one C structure into another

I have two identical (but differently named) C structures: typedef struct { double x; double y; double z; } CMAcceleration; typedef struct { double x; double y; double z; } Vector3d; Now I want to assign a CMAcceleration variable to a Vector3d variable (copying the whole struct). How can I do this? ...

What is the default encoding for C strings?

I know that C strings are char[] with a '\0' in the last element. But how are the chars encoded? Update: I found this cool link which talks about many other programming languages and their encoding conventions: Link ...

Call same instance of a program?

Hello I am creating a C program that is called from a shell script when a specific event is occurring. The C program gets an argument from the shell script like this: > ./c-program.bin HELLO Now the C program is running until it recieves a specific character as an argument. The problem is that if a second event occurs, and the C prog...

Automated FSM for C

I am looking for a automated finite state machine generator for C? I have seen a few over the internet but unable to decide which one to use. If anybody worked with any such tool then help me to find the right one. Thanks, Ravi Gupta ...

Calling "start" to start program and "stop" to close current instance in C

I wrote a simple server in C and would like to have the same functionality calling it as other C daemons (such as calling it with ./ftpd start and closing that instance with ./ftpd stop). Obviously the problem I'm having is that I do not know how to grab the current instance of the running program. I can parse the options just fine (usin...

Best way to pass data between two servers in C?

I wrote a program that creates a TCP and UDP socket in C and starts both servers up. The goal of the application is to monitor requests over the TCP socket as to what UDP packets to send it (i.e. monitor for something like "0x01 0x02" and if I see it, then have the UDP server parse the payload, and forward it over to the TCP server for p...

Memory use visual monitoring

Hi! I'm developing a software in C that uses a lot of memory and I need to monitor this. I know netbeans has this option but it needs Sloaris Studio. Do you know some grafical tool to watch the use of memory, CPU and is possible I/O? How do you usually do this things? PD: I know valgrind to search for memory leaks, but I'm searching s...

Array size optimization

Is there any advantage defining an array's size to be a multiple of 8, if using 64 bit UNIX OS? I am intended to use this array for loading data from shared memory. So dependencies may exist on the operating system and the page size. ...

Exiting gracefully from a multithreaded process

I'm running a multi-threaded C program (process?) , making use of semaphores & pthreads. The threads keep interacting, blocking, waking & printing prompts on stdout continuously, without any human intervention. I want to be able to exit this process (gracefully after printing a message & putting down all threads, not via a crude CTRL+C S...

Removal of items with duplicate data.

Hi I'm writing a function that removes the consecutive items with duplicate data . e.g For example, passing in the list ->a->b->c->c->a->b->b->b->a->null should result in ->a->b->c->a->b->a->null The list item definition and function declaration are given below struct litem { char data; litem* next; }; Mo code lo...

Passing whole array to a function.

when we pass an element of an array to a function, it is treated as an normal variable and the called function creates a copy of the actual argument and operates on it.Any changes made in the formal arguments doesn't affect the actual arguments. But this not the case when we pass a whole array. In this case it(called function) gets acce...

Is it worth writing part of code in C instead of C++ as micro-optimization?

I am wondering if it is still worth with modern compilers and their optimizations to write some critical code in C instead of C++ to make it faster. I know C++ might lead to bad performance in case classes are copied while they could be passed by reference or when classes are created automatically by the compiler, typically with overloa...

Beginner path to Game Development for OS X and iPhone

Another question. I have been researching everything this wonderful community has offered me in terms of my journey to pursue game development. I have come to the conclusion that I would prefer to develop on my native machine, OS X - eventually leading to the iPhone. I already own both Big Nerd Ranch guide's, Iphone Programming - the ...

Allocate Virtual memory before running out of RAM

is it possible, in a C/C++ program, to allocate virtual memory (Swap Space) for an specific array, so that the program keeps using RAM for the rest of variables, and maybe getting some benefit at some type of problems?? ...

Casting function returns to void

Many times I see in open source code that a call to a C function is cast to void. For example, in the source code for ls (http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/ls/ls.c) I see the following. (void) setlocale(LC_ALL, ""); Why is this good practice? ...