c

What can I do if getcwd() and getenv("PWD") don't match?

I have a build system tool that is using getcwd() to get the current working directory. That's great, except that sometimes people have spaces in their paths, which isn't supported by the build system. You'd think that you could just make a symbolic link: ln -s "Directory With Spaces" DirectoryWithoutSpaces And then be happy. But u...

How to represent a Python-like dictionary in C

Hello, In Python it's easy: x = {} x['USD'] = "Dolars" x['CLP'] = "Pesos" or y = {'lat': 23.678900, 'lng': 121.451928, 'name': "Sin City"} I think most of these kind of problems are solved so where can I get information about dictionaries in C? I don't want to reinvent the wheel. How do I implement a dictionary in C? ...

Blur with OpenGL?

I'm using OpenGL and drawing polygons in a 2D view. How could I blur a polygon, without using glsl, and only things like stencil buffer and stuff. Thanks ...

How do vector applications skew polygons?

I know how to move, rotate, and scale, but how does skewing work? what would I have to do to a set of verticies to skew them? Thanks ...

non-IDE C development environment

How do I set up a non-IDE-based C development environment on Linux? ...

C - System(""); Execute one at a time

Hello!, I've got a system("sudo apt-get update | sudo apt-get -y install apache2 zip unzip"); etc, but its doing all the same commands at once?, how do i make it so it does one after the other is finished?, also some may ask the user to enter information from apt-get, how do i allow this to show? ...

Can gdb make a function pointer point to another location?

I'll explain: Let's say I'm interested in replacing the rand() function used by a certain application. So I attach gdb to this process and make it load my custom shared library (which has a customized rand() function): call (int) dlopen("path_to_library/asdf.so") This would place the customized rand() function inside the process' m...

Need some help porting this C code to C#

I am not very good at c at all. I have tried to capture the essense of what the C code does in C# using this wikipedia article. However my version is totally different and does not achive the same compression that the C code does. Therefore, I'd like to port the following code from C to C#. However, i do not need it to read/write to file...

How do i get the lower 8 bits of int?

Hey guys Lets say I have an int variable n = 8. On most machines this will be a 32 bit value. How can I only get the lower 8 bits (lowest byte) of this in binary? Also how can i access each bit to find out what it is? My question is related to C ...

Distorting a polygon (Like Photoshop's distort) (Perspective Transformation)

In Photoshop there is a tool that allows the selection to be "Distorted". This allows easy shadow creation among other things. How could this sort of distortion be applied for a polygon (a bunch of points)? Thanks ...

C is support web application

Whether C is Suitable for Web application ...

strcat problem with char *a[10]

hey, here's my code #include <stdio.h> #include <string.h> int main() { char *array[10]={}; char* token; token = "testing"; array[0] = "again"; strcat(array[0], token); } why it returns Segmentation fault? I'm a little confused. ...

How to send float over serial

Whats the best way to send float, double, int16 over serial on Arduino? The Serial.print() only sends values only ascii encoded. But I want to send the values as bytes. Serial.write() accepts byte and bytearrays, but whats the best way to convert the values to bytes? I tried to cast an int16 to an byte*, without luck. I also used memcpy,...

How can I detect one or combination of strokes of keys in C?

How can I detect one or combination of strokes of keys in ANSI C and/or with Win32 SDK? For example: how can I detect CTRL+ALT+DEL was pressed? Please provide me with some source code or any web-link. Please note that, I am using polling mechanism, not event. I need to do it in win32 console mode. ...

Blitting zoomed images using SDL

Is there any way to Blit a zoomed (in) version of a certain image/sprite using SDL? (Besides manually saving a zoomed version of the image..) Thanks :-) ...

Accessing variables in a union inside a struct

Can anyone please explain why the 1st method of accessing a nested struct element inside an union in a struct works and the 2nd does not? typedef struct element Node; struct element { int type; union { int value; Node *child[2]; } u; }; int main() { Node n; Node *p; n.type = 0; p = n.u...

Cross Compiling on mac os x

Hi, How do i compile my c programs on mac os x, so they work on linux oses?, i've searched google for this but i seam to only get results the other way around? ...

How do you send AT commands using Dynamic C through Rabbit 2000 controller connected to a GSM modem?

First, I am working on a project that opens an electric door when certain cell phones call the GSM modem's SIM card's number. But, as a starting point I want to send some AT commands to the modem, then from there I can continue. Here is the code I wrote so far: #define CINBUFSIZE 255 #define COUTBUFSIZE 255 #define TIMEOUT 500 char mode...

How much is memory usage likely to grow when moving to 64bit?

When moving an application from 32bit to 64bit, where will increased memory usage occur? I understand that pointers will double in size, I suspect that the chars in a string are 'bunched' to use memory more efficiently (so will not use much more memory). Where else would memory usage increase? Is there anywhere that it would decrease, ...

Representation of float in C

Hi, I was trying to understand the floating point representation in C using this code (both float and int are 4 bytes on my machine): int x = 3; float y = *(float*) &x; printf("%d %e \n", x, y); We know that the binary representation of x will be the following 00000000000000000000000000000011 Therefore I would have expected y to be...