c

Why this code doesn't allocate memory in C?

Updated question is here http://stackoverflow.com/questions/828108/please-help-me-to-solve-this-memory-allocation-problem I'm working on making a HashTable in C. This is what I've done. I think I'm going on a right path but when I'm trying to main.c HashTablePtr hash; hash = createHashTable(10); insert(hash, "hello"); insert(hash, "...

Python-style integer division & modulus in C

In Python and Ruby, signed integer division truncates towards negative infinity, and signed integer modulus has the same sign the second operand: >>> (-41) / 3 -14 >>> (-41) % 3 1 However, in C and Java, signed integer division truncates towards 0, and signed integer modulus has the same sign as the first operand: printf("%d\n", (-41...

Memory allocation problem in HashTable

Please don't close this saying a duplicate question. I made an important change so not to confuse people, I resubmitted this much clearer codes. Please help me to solve this memory allocation problem. I'm working on a HashTable and this is what I've (partial codes only) main.c HashTablePtr hash; hash = createHashTable(10); insert(hash...

How do I install nano-hmac on Mac OS X?

"nano-hmac" is a Haskell package which can normally be installed using Cabal. However, Mac OS X has a different OpenSSL library than the one it expects, so it fails to compile bindings. I can install the version of openssl from openssl.org, but I'm not sure how to instruct Cabal to use this instead of the Mac OS X version. ...

How do we shift from protected mode to real mode in Linux 2.6?

How do we shift from protected mode to real mode in Linux 2.6? ...

Determining the type of an expression

Sometimes I need to learn the type of an expression while programming in C or C++. Sometimes there's a good IDE or existent documentation to help me, but sometimes not. I often feel such a construct could be useful: void (*myFunc)(int); printf("%s", nameoftype(myFunc)); //"void (*)(int)" int i, unsigned int u; printf("%s", nameoftype(i+...

What’s the easiest way to grab a web page in C ? (via https)

Almost the same question as this one here: http://stackoverflow.com/questions/825327/whats-the-easiest-way-to-grab-a-web-page-in-c however the conditions have changed and I need to connect via https, this is a bit more tricky, anyone got any snippets? I am on a qnx platform, building and compiling additional libraries and rolling it ou...

How would you access a C structure's members without knowing the name?

I'm dealing with an undocumented API that I'm trying to do a bit of reverse engineering on - don't worry this isn't malicious, just trying to fulfill a use case in a creative way. I've got a pointer to a C structure. Is there a way for me to determine by examining the memory how many members this structure has? Their values? I suspec...

Issue with WPF Focus

I have code that handles the LostFocus event of my controls. It validates the value and in some cases will enable a subsequent control. For instance, there might be a ComboBox that allows a user to select a country. The subsequent ComboBox allows the user to select a state. IF the currently selected country is not the USA, the state ...

LD_LIBRARY_PATH

Can I set LD_LIBRARY_PATH for an individual application? I am looking into system call failure, so is there any way I can set set the correct path using the LD_LIBRARY_PATH setting? ...

Formatting a (large) number "12345" to "12,345"

Say I have a large number (integer or float) like 12345 and I want it to look like 12,345. How would I accomplish that? I'm trying to do this for an iPhone app, so something in Objective-C or C would be nice. ...

linked list problem in c: the print function deletes the value from my list

As a part of an assignment, I need to write two functions: a function that sums up two natural numbers represented as a linked list a functions that prints a number represented in the same way. for some reason, both function work perfectly fine separately, but when I try to use the print function on the result of the sum function, i...

GraphViz edge labels

Hi... I'm trying to draw a graph of the dependencies between C header files using graphviz. Basically, what I'm doing is log all the #include that appear and the condition (#if conditions I mean). If a file includes another one, it becomes its father in the graph and the potential condition is the edge label. I obtain a pretty large g...

Determining the (opened) filename from a FILE *

Given a stdio FILE * pointer, is there a method by which I can discover the name of the (opened) file? ...

C/C++ 'continue' Equivalent in VB6

Is there a VB6 equivalent to the C/C++ 'continue' keyword? In C/C++, the command 'continue' starts the next iteration of the loop. Of course, other equivalents exist. I could put the remaining code of the loop in an if-statement. Alternatively, I could use a goto. (Ugh!) ...

How to change processor stack?

Why doesn't this code print "test"? #include <stdio.h> #include <stdlib.h> void foo ( void ) { printf("test\n"); } __declspec(naked) void bar ( void ) { asm { push 0x000FFFFF call malloc pop ecx push eax add eax, 0x000EFFFF mov ecx, esp mov esp, eax push ecx call foo ...

glibc and SSE functionality

I am trying to find information on glibc and to what extent it uses SSE functionality. If it is optimized, can I use it out-of-the-box? Say I am using one of the larger Linux distros, I assume that its glibc is compiled to be as generic as possible and to be as portable as possible, hence not optimized? I am particular interested in ...

Unresolved symbols when compiling with gcc on OpenSolaris 2008.11

When compiling a simple Netbeans C project that uses sockets I get the following output. I supose the problem is that gcc is not properly linking sockets.h library. Need a foolprof method to solve this. Thanks i advance Running "/usr/bin/make -f Makefile CONF=Debug clean" in /export/home/manu/Escritorio/TP-entrega 2/Application_1 /usr...

Making a Grid in GTK+

I'm not asking for a code implementation, but given GTK+'s skillset, what would be from an abstract perspective the best way to implement a grid such that each square is clickable and the like? ...

When to use restrict and when not to

I have a general understanding of restrict but I'm hoping to clarify some fine points. I have a function that reads a null-terminated string from one buffer and writes out a URL encoded version in another buffer. The function has this signature (currently without restrict): char const *StringUrlEncode(char const *unencoded, ...