c

How to get FFTW to work in Eclipse CDT on windows XP

I'm trying to get the Fastest Fourier Transform in the West to cooperate with eclipse. I downloaded it from the website (it's a big folder called fftw-3.2.2 filled with other folders with names api, dft, cell, doc, kernel, fdft and more, each filled with .h and .c files). I've tried going to project>Properties>MinGW C linker>Libraries>...

Qsort based on a column in a c-string?

A class project involves sorting an array of strings, with each string containing an equal number of columns like this: Cartwright Wendy 93 Williamson Mark 81 Thompson Mark 100 Anderson John 76 Turner Dennis 56 The program accepts a command-line argument for which column to sort on, and should print ou...

C - strtok and strcmp

I am having a bit of trouble using strtok with strcmp. //Handles the header sent by the browser char* handleHeader(char *header){ //Method given by browser (will only take GET, POST, and HEAD) char *method,*path, *httpVer; method = (char*)malloc(strlen(header)+1); strcpy(method,header); method = ...

What is the difference between the ways to create a string in C?

What is the difference between these two forms of a string variable in C language? char *string1; char string2[]; Is there any other way to do it? Thank you very much. ...

Representing a 2D array as a 1D array

Possible Duplicates: Implementing a matrix, which is more efficient - using an Array of Arrays (2D) or a 1D array? Performance of 2-dimensional array vs 1-dimensional array I was looking at one of my buddy's molecular dynamics code bases the other day and he had represented some 2D data as a 1D array. So rather than having to...

How to format a number from 1123456789 to 1,123,456,789 in C?

Hi All, How can I in C language format a number from 1123456789 to 1,123,456,789? I tried using printf("%'10d\n", 1123456789); but that doesn't work. Could you advice anything? The simpler the solution the better. Thanks, goe ...

What are the semantics of C99's "restrict" with regards to pointers to pointers?

I am doing lots of matrix arithmetic and would like to take advantage of C99's restrict pointer qualifier. I'd like to setup my matrices as pointers to pointers to allow for easy subscripting, like so: int **A = malloc (ncols * sizeof(int *)); A[0] = malloc (nrows * ncols * sizof(int)); for (int i=1; i < ncols; i++) { A[i] = A[0] +...

building a .so that is also an executable

So everyone probably knows that glibc's /lib/libc.so.6 can be executed in the shell like a normal executable in which cases it prints its version information and exits. This is done via defining an entry point in the .so. For some cases it could be interesting to use this for other projects too. Unfortunately, the low-level entry point y...

Help While Loop in C

I'm new to C programming, I come from a Java background. I was wondering why in the following code, in the while loop I have to type my input ten times and then all ten inputs are displayed. I'm trying to type something once and have it displayed right after. Then continue typing my other inputs. #include <stdio.h> #include <stdlib.h> ...

Simple program adding "D" to output

I have a very simple program that just prints the number of newlines as an integer and I get a "D" after every number. Sample input: d [enter] e [enter] f [enter] Ctrl-D [enter] Sample output: 3D What am I doing wrong? This is verbatim from The C Programming Language 2nd edition, pg. 19: #include <stdio.h> main() { int c...

Installing gtk and compiling using gcc under windows?

I have gcc installed in c:/programfiles (also set as a path variable), and i have all the necessary files for gtk from http://www.gtk.org/download-windows.html, glib,gtk,pango,atk and cairo. Although I have no clue as to how to compile a c program using gtk with the gcc compiler. How do I set everything up so that it works?. (I don't kno...

Eclipse CDT with Cygwin GCC: automatic discovery of symbols and paths

I am using Eclipse CDT with Cygwin GCC as compiler. My project is using a custom Makefile.The problem is that when debugging the code, it couldnt locate the source files, even though I added a custom path mapping for: /cygdrive/c <-> c:\ That in addition to the fact that I am getting "unresolved inclusion" for all standard header files,...

commonly used c libraries for applications?

What are the most commonly used c libraries that are used in applications. Not specific to anything but just in general? ...

C if condition not working as expected

All, I come from java and php world so this maybe a factor. But I have a problem with: printf("%s\n",data[0]); if(data[0] == "BG01") { printf("%s\n",otherstring); } The problem is that first printf returns in the console "BG01" but for some reason the IF condition doesn't pick up on it and the second printf never gets executed. ...

Folder structure for a C project

Hey guys, which options do we have for the folder structure of a C project? I also would like to do TDD, so I need that that structure accommodates a test directory. What do you think? ...

Examples of compiling win32 api c programs (through command line) on windows

Attempting to do something very simple - compile basic win 32 c programs through windows cmd. This is something I should be able to do myself, but I am just so stuck here.. I keep stumbling into weird problems, vague errors. I dunno whether I should go into details. Using tcc ( tiny c compiler) One simple hellowin.c example from a b...

Expand Tabs to Spaces in C?

I need to expand tabs in an input line, so that they are spaces (with a width of 8 columns). I tried it with a previous code I had replacing the last space in every line greater than 10 characters with a '\n' to make a new line. Is there an way in C to make tabs 8 spaces in order to expand them? I mean I am sure it is simple, I just c...

Is this a good way to be root in a makefile?

Is this a good way to be root in a makefile? SHELL = /bin/sh INSTDIR = /usr/bin/ OBJS = main.o file.o gen.o stat.o program1: $(OBJS) gcc -o program1 $(OBJS) main.o: main.c file.h gen.h stat.h gcc -c main.c file.o: file.c file.h gcc -c file.c gen.o: gen.c gen.h gcc -c gen.c stat.o: stat.c stat.h ...

Is there a way to diff files from C++?

I'm looking for a C or C++ diff library. I know I can use the Unix diff tool in combination with system or exec, but I really want a library. It would be handy if the library could perform patches as well, like the Unix patch tool. ...

C Programming. Printing current user

In C programming how do you get the current user and the current working directory. I'm trying to print something like this: asmith@mycomputer:~/Desktop/testProgram:$ (user) (computerName) (current directory) I have the following code, but the username is showing as NULL. Any ideas what I'm doing wrong? void prompt() { pr...