c

Equivalent of CGPoint with integers?

Cheers, I like strict typing in C. Therefore, I don't want to store a 2D vector of floats if I specifically need integers. Is there an Apple-provided equivalent of CGPoint which stores data as integers? I've implemented my type Vector2i and its companion function Vector2iMake() à la CGPoint, but something deep in me screams that Apple ...

Why fork() before setsid()

Why fork() before setsid() to daemonize a process ? Basically, if I want to detach a process from its controlling terminal and make it a process group leader : I use setsid(). Doing this without forking before doesn't work. Why ? Thanks :) ...

what does this C++ line of code mean "sol<?=f((1<<n)-1,i,0)+abs(P[i])*price;"

Could anyone help me to understand following line of code: sol< ?=f((1<< n)-1,i,0)+abs(P[i])*price; I am studying an algorithm written using c++ and it has following operator < ?= . My problem is with understanding < ?= operator. Also when I compile this code using g++ compiler , it gives error message for above line of code line of c...

Extracting public key from private key in OpenSSL

Hello, I need to extract the RSA public key from a RSA private key using OpenSSL. I'm currently using RSAPublicKey_dup() passing the RSA* private key to get the public key. However, while the call seems to work, I cannot load (or use) this public key using the openssl command-line tool. If I generate the public key using the command-l...

How do I use multiple arguments from an array to construct an execl() call in C?

I have a string array in C named args[] - now how can I use this list of arguments to construct a proper call to execl()? So if the array contains: {"/bin/ls","ls","-a","-l"} ...how can I eventually construct an execl() call that is: execl("/bin/ls","ls","-a","-l",NULL); I must be thinking about this wrong, as I can't find anythi...

code crashes when int arr = 1 && arr; but not int arr = 0 && arr;

Hi, I wanted to know why the following code crashes. int main( ) { int arr = 1 && arr; return 0; } BUT not with the below code int main( ) { int arr = 0 && arr; return 0; } Thanks in advance ...

Priority queue implementation in C

Is there any reliable and simple priority queue (linked list preferred, not necessary) implementation for C? More generally, what C standard libraries do you use? ...

Cannot Open Shared Object cygmpfr-1.dll

I'm testing CeGCC, that is a gcc built to cross-compile applications to Windows CE devices. As everyone do to test compilers, I've done a Hello World program: #include <stdio.h> int main() { printf("Hello, World!"); return 0; } As I'm using Windows now(because this is my other laptop), I'm using Cygwin. But when I tried to comp...

C compiler producing lightweight executeables

I'm currently using MSVC for C++ but as I'm switching to C to write a very performance-intensive program (interpreter) I have to search for a fitting C compiler. I've looked at some binaries produced by Turbo-C and even if its old they seem pretty straigthforward and optimized. Now I don't know what the best compiler for building an in...

parsing/matching string occurrence in C

I have the following string: const char *str = "\"This is just some random text\" 130 28194 \"Some other string\" \"String 3\"" I would like to get the the integer 28194 of course the integer varies, so I can't do strstr("20194"). So I was wondering what would be a good way to get that part of the string? I was thinking to use #in...

dynamic memory for 2D char array

I have declared an array char **arr; How to initialize the memory for the 2D char array. ...

dlopen / dlsym with as little linking as possible

I have an application which can make use of plugins which are loaded at runtime using dlopen. Each of the plugins defines a function toretrieve the plugin information which is defined using a common structure. Something like that: struct plugin { char *name; char *app_version; int app_verion_id; char *plugin_version; ...

function prototype declarations

I am practice the function in c and come across to the program .... #include<stdio.h> int main() { float a=15.5; char ch ='C'; printit(a,ch); return 0; } printit(a,ch) { printf("%f\n%c",a,ch); } I want to know that why the above program compile and not give the error as i understood so for is ... The function i...

What's the difference between alloca(n) and char x[n]?

What is the difference between void *bytes = alloca(size); and char bytes[size]; //Or to be more precise, char x[size]; void *bytes = x; ...where size is a variable whose value is unknown at compile-time. ...

Switching from C++ (with a lot of STL use) to C for interpreter building

I'm switching from C++ to C because I'm rebuilding my toy interpreter. I was used to vectors for dynamic allocation of objects like tokens or instructions of my programs, stacks and mainly strings with all their aspects. Now, in C I'm not going to have all these anymore. I know that I will have to use a lot of memory management, too. ...

Need some help understanding a weird C behavior

This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] = "abc"; int i, j; int count = 5; for((i=0) && (j=0); count > 0; i++ && j++){ printf("i = %d and j = %d\n", i, j); count--; } return 0; } The output as expected: i : 0 and j : 0 i : 1 and j : 1 i : 2 and j...

lvalue Required

Can anyone tell me in simple words that what this L value is and why I'm coming across the error "L Value required in function main()"? ...

How can I check the network connection type using the Windows API?

How can I programmatically retrieve the current connection type (eg. LAN or Direct connection)? InternetGetConnectedState() isn't very reliable. For instance, I'm connected to a wireless network, but ConTypeRet is 18, which is INTERNET_CONNECTION_LAN & INTERNET_RAS_INSTALLED. Isn't there any way to make sure that ConTypeRet is either I...

Profiling python C extensions

I have developed a python C-extension that receives data from python and compute some cpu intensive calculations. It's possible to profile the C-extension? The problem here is that writing a sample test in C to be profiled would be challenging because the code rely on particular inputs and data structures (generated by python control co...

Get list of windows in taskbar on Windows 7?

Hi, how can I get a list of windows shown on the taskbar on Windows 7? I have tried EnumWindows, but I'm getting way more windows than those shown on the taskbar (800 vs 15). ...