c

What is the definitive link for C programming language?

Lately all modern programming languages have a definitive web site to support, distribute, learn the programming language, as well as community forums, e-mail lists and so on. Java has java.sun.com, python has python.org, etc. However C/C++ does not seem to have such a site. Which site do you use, say in a document, to link for C or C+...

C makefile to compile OpenGL project directly on iphone

Please direct me if this question has already been asked; I did a search on the topic unable to find yet. I am having trouble putting together a makefile that will take one or more .c OpenGL project files, uses apple-arm-darwin9 and OpenGL framework to compile into object directly on the iphone (using bash). For some reason whatever com...

How do I source/link external functions in C or C++?

EDIT: I suppose I should clarify, in case it matters. I am on a AIX Unix box, so I am using VAC compilers - no gnu compilers. End edit I am pretty rusty in C/C++, so forgive me if this is a simple question. I would like to take common functions out of a few of my C programs and put them in shared libraries or shared objects. If I w...

What is the fastest way(s) to loop through a large data chunk on a per-bit basis.

I am running through a memory block of binary data byte-wise. Currently I am doing something like this: for (i = 0; i < data->Count; i++) { byte = &data->Data[i]; ((*byte & Masks[0]) == Masks[0]) ? Stats.FreqOf1++; // syntax incorrect but you get the point. ((*byte & Masks[1]) == Masks[1]) ? Stats.FreqOf1++; ((*byte ...

Debugging Howto

Hi. I am new to C and I am using MS Visual C++ 6.0 for now. I am currently working on sorting algorithms and i want to track the values of each variable automatically. This may provide me insight on how the algorithm does the hard work. That is, I don't want to write what is produced by what on a paper :) Are there are any operators or f...

K&R Exercise 2-4

I'm learning how to write programs in C using the k&r book (The C Programming Language) and I have a problem with one of the exercises. It's asking me to detect and remove a character in string s1, which matches any characters in the string s2. So, say s1 = "A"; And s2 = "AABAACAADAAE" I want it to return "BCDE" I know I'm on the rig...

Why is C so fast, and why aren't other languages as fast or faster?

In listening to the StackOverflow podcast, the jab keeps coming up that "real programmers" write in C, and that C is so much faster because it's "close to the machine." Leaving the former assertion for another post, what is special about C that allows it to be faster than other languages? Or put another way: what's to stop other language...

char x[256] vs. char* = malloc(256*sizeof(char));

Someone here recently pointed out to me in a piece of code of mine I am using char* name = malloc(256*sizeof(char)); // more code free(name); I was under the impression that this way of setting up an array was identical to using char name[256]; and that both ways would require the use of free(). Am I wrong and if so could someon...

How does one calculate 2 ^ -18 using GMP?

I've just discovered, to my embarrassment, that feeding negative exponents to mpz_pow_ui doesn't work very well. ("The manual does say unsigned long, you know.") For the other mpz_pow functions, the manual uses concepts I don't understand. For example "base^exp mod mod" in the following: void mpz_powm (mpz_t rop, mpz_t base, mpz_t exp, ...

What is the best open source example of a lightweight Windows Application?

I would like to learn how a program can be written and installed without the use of the .net framework. I'm looking for a project that is known to be lightweight and robust. Something like the uTorrent client. ...

Grabbing text from a webpage

I would like to write a program that will find bus stop times and update my personal webpage accordingly. If I were to do this manually I would Visit www.calgarytransit.com Enter a stop number. ie) 9510 Click the button "next bus" The results may look like the following: 10:16p Route 154 10:46p Route 154 11:32p Rou...

Using strcat in C

Okay so I have the following Code which appends a string to another in C#, note that this is Just an example, so giving alternative string concatination methods in C# is not nessesary, this is just to simplify the example. string Data = ""; Data +="\n\nHTTP/1.1 " + Status_code; Data += "\nContent-Type: " + Content_Type; Data += "\nServe...

Cant declare variables after statements in DevC++

Hey guys, The trouble here is that i cant declare variables inside a function after the function already has some statements in it. Declaring at the start works fine, but after something, it gives a parse error. for example: int main() { int b; b = sisesta(); float st[b]; return 0; } Id like to declare an array st with its size ...

rounding shortcuts in C

I am working in C to implement pseudo-code that says: delay = ROUND(64*(floatDelay - intDelay)) where intDelay = (int) floatDelay The floatDelay will always be positive. Is there an advantage to using the round function from math.h: #inlcude <math.h> delay=(int) round(64*(floatDelay-intDelay)); or can I use: delay=(int)(64*(floatD...

Convert MYSQL_TIME data type to char * or C++ string

I am using the MySQL C API within a C++ application. I have a column in my result set that is of the type MYSQL_TIME (part of mysql.h). Is there a way to convert MYSQL_TIME to a char* or to a C++ string? ...

How to set the locale for a process launched by CreateProcess()

When launching a process with CreateProcessW(), is it possible to have the process created with a different MBCP locale/codepage then the one that is configured as the system-wide default code page? In the target process, this should have the same effect as calling _setmbcp(). The target process is not a unicode-enabled and uses a plain...

Is endian conversion required for wchar_t data?

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value on the other side? Or will the bytes need to be swapped? ...

How to copy a few chars from a char[] to a char* in C?

Yo! I'm trying to copy a few chars from a char[] to a char*. I just want the chars from index 6 to (message length - 9). Maybe the code example will explain my problem more: char buffer[512] = "GET /testfile.htm HTTP/1.0"; char* filename; // I want *filename to hold only "/testfile.htm" msgLen = recv(connecting_socket, buffer, 512, 0...

C/C++: Capture characters from standard input without waiting for enter to be pressed

I can never remember how I do this because it comes up so infrequently for me. But in C or C++, what is the best way to read a character from standard input without waiting for a newline (press enter). Also ideally it wouldn't echo the input character to the screen. I just want to capture keystrokes with out effecting the console screen...

Running/Interpreting C on top of the JVM?

Is there a way to run plain c code on top of the JVM? Not connect via JNI, running, like you can run ruby code via JRuby, or javascript via Rhino. If there is no current solution, what would you recommend I should do? Obviously I want to use as many partials solutions as I can to make it happen. ANTLR seems like a good place to start, ...