c

Derivatives in C/C++?

I have some expressions such as x^2+y^2 that I'd like to use for some math calculations. On of the things I'd like to do is to take partial derivatives of the expressions. So if f(x,y) = x^2 + y^2 then the partial of f with respect to x would be 2x, the partial with respect to y would be 2y. I wrote a dinky function using a finite differ...

Any good online C book

I've (re)started working in C after about 3 years:) And i discovered that my C language skills arent that good anymore. Can anyone recommend an online book for C? (not C++) It should cover the basic functions, plus pointers, and working with linear lists, reading from files..etc. This things are covered by basically any book for beginne...

What's the most pythonic way of access C libraries - for example, OpenSSL?

I need to access the crypto functions of OpenSSL to encode Blowfish data in a CBC streams. I've googled and found some Blowfish libraries (hand written) and some OpenSSL wrappers (none of the seem complete.) In the end, I need to access the certain OpenSSL functions, such as the full blowfish.h library of commands. What's the pythonic/r...

Is this dynamic memory allocation?

Simple question: do I have to 'delete' or 'delete []' c? Does the language matter? char c[] = "hello" ...

Since I can't return a local variable, what's the best way to return a string from a C or C++ function?

As a follow-up to this question: From what I've seen, this should work as expected: void greet(){ char c[] = "Hello"; greetWith(c); return; } but this will cause undefined behavior: char *greet(){ char c[] = "Hello"; return c; } If I'm right, what's the best way to fix the second greet function? In an embedded environme...

What size should I allow for strerror_r?

The OpenGroup POSIX.1-2001 defines strerror_r, as does The Linux Standard Base Core Specification 3.1. But I can find no reference to the maximum size that could be reasonably expected for an error message. I expected some define somewhere that I could put in my code but there is none that I can find. The code must be thread safe. Whic...

Use of CoGetClassObject() in C - access COM Object interface

Instruction on accessing a interface to an application, in plain C/C++ without: MFC ATL WTL Basically, I would like to make use of a COM object. Working sample source code or guidance - to using (functionality) a COM object, not creating a COM server. Regards ...

Passing multi-dimensional arrays in C

Hey guys, I am currently trying to learn C and I have come to a problem that I've been unable to solve. Consider: #include <stdio.h> #include <stdlib.h> #include <string.h> #define ELEMENTS 5 void make(char **array, int *array_size) { int i; char *t = "Hello, World!"; array = malloc(ELEMENTS * sizeof(char *)); for ...

Get MIME type from filename in C

I want to get the MIME type from a filename using C. Is there a way to do this without using a textfile containing MIME types and file extensions (i.e. Apache's file mime.types)? Maybe there is a function to get the MIME type using the filename? I rather not use the file extension if I don't have to. ...

How to include/link C .lib files in a Delphi project.

We have a .lib file with functionality that must be included in a Delphi application. It is easy to include .obj files, but for some unknown reason, this won't work for .lib files. The help is not very helpful on this. And a google search did not help that much (most helpful was to use an other linker but I would like to avoid it if pos...

easy way to add 1 month to a time_t in C/C++

I have some code that uses the Oracle function add_months to increment a Date by X number of months. I now need to re-implement the same logic in a C / C++ function. For reasons I don't want/need to go into I can't simply issue a query to oracle to get the new date. Does anyone know of a simple and reliable way of adding X number of m...

What alternatives to Hans Boehm GC are out there for small devices?

I'd like to use a virtual machine like NekoVM into a small device but to build it, it requires Boehm GC, however there is no port of that GC to that small device so I was wondering if there is any alternative to it, something that could be done exclusively with C code? ...

What is the relationship between the Windows API and the C run time library?

What is the relationship between the Windows API and the C run time library? ...

Difference between C/C++ Runtime Library and C/C++ Standard Library.

Can you guys tell me the difference between them? BTW is there something called C++ library or C library?? Thanks. Dazza ...

Profiling a multi-process program

I'd like to profile a program that forks and spawns several child processes. I want to see how much time is spent in some of the functions. What profiler can handle this job? ...

How to free a C struct with Objective-C?

Given a struct, e.g. typedef struct { int value; } TestStruct; Why does the following code (in the context of an Objective-C class running on the IPhone) throw a "non-aligned pointer being freed" exception? TestStruct ts = {33}; free(&ts); N.B. My uber goal is to use a C library with many vector-math functions, hence the need to ...

On which kind of memory a C struct is allocated when initialized as a class variable in Objective-C

Consider the following: typedef struct { float m00, m01, m02, m03; float m10, m11, m12, m13; float m20, m21, m22, m23; float m30, m31, m32, m33; } Matrix; @interface TestClass : NSObject { Matrix matrix; } - (TestClass *) init; @end @implementation TestClass - (TestClass *) init { self = [super init]; matrix = (Matri...

What is the LD_PRELOAD trick?

I came across a reference to it recently on proggit and (as of now) it is not explained. I suspect this might be it, but I don't know for sure. ...

Problem with OpenSSL library

Hello, I try to encrypt simple text with RSA algorithm. I have a problem with my code. RSA *_RSA ; unsigned char text[2560] = "A"; unsigned char sectext[2560]; unsigned char decrypttext[2560]; int i = 0; _RSA = RSA_generate_key ( 1024, 65537, NULL, NULL ); i = RSA_public_encrypt ( 1, text, sectext, _RSA, RSA_PKCS1_OAEP_PA...

compile c code in vs 2005

Is there an easy way to compile c code in visual studio 2005? Its been a while(2-3 years) since I've done any coding in either c or c++, but I remember that you used to be able ti, in vs 2003, compile c code in visual studio. I thought it was just a matter of using an empty project(rather than, say a c++ project or a C# project) and gi...