c

Is there a library or other way to do 128-bit math operations?

I am writing a cryptography application and need to work with 128 bit integers. In addition to standard add, subtract, multiply, divide, and comparisons, I also need a power and modulo function as well. Does anyone know of a library or other implementation that can do this? If not 128-bit, is there a 64-bit option available? ...

Compile multiple C files with make

(I am running Linux Ubuntu 9.10, so the extension for an executable is executablefile.out) I am just getting into modular programming (programming with multiple files) in C and I want to know how to compile multiple files in a single makefile. For example, what would be the makefile to compile these files: main.c, dbAdapter.c, dbAdapte...

Deciphering (*(void(*)())0)()

They said this expression is valid in C, and that it means calling a function: (*(void(*)())0)(); Can someone clearly explain what this expression means? I tried to compile this and was surprised that it didn't result in an error. ...

stat() get group name is root

I have a file src.tar.gz whoes owner and group are named "src". When I run test.c compiled with name "test" (permission: -rwsr-xr-x owner:root group:staff) The way I run it: I am running it as group member under "src" group. But I run "test" as root since "test" permission is -rwsr-xr-x Question: Why did result come out like this? i...

How can I use ToUnicode without breaking dead key support?

A similar question has already been asked, so I'm not going to waste time re-explaining it, an existing discussion can be found here: http://stackoverflow.com/questions/1964614/toascii-tounicode-in-a-keyboard-hook-destroys-dead-keys The reason I'm posting a new question however is that I seem to have come across a 'solution', but I'm no...

*nix: "echo 'start working' > /etc/.example" : how is this implemented?

Say someone executes the following in a terminal: echo 'start working' > /etc/.example and when this is executed, the example program would "start working." On UNIX(-like) systems, how would something like that be implemented, and what is this kind of behavior called? ...

Manipulate the Clipboard in C on Mac OS X

How do you copy text to the clipboard in C or with a Command-Line command? ...

Gnu Emacs indenting of my typedef

Gnu Emacs is insisting on indenting my typedef as follows: typedef enum { horizontal, vertical, } shapes; I want it to indent as follows: typedef enum { horizontal, vertical, } shapes; What switch can I use to get that? ...

Stack storage at function call

When we call a function (let say with 3 parameters), how are the variables are stored in the stack memory. ...

C: Extrapolating type from void pointer

Say a function takes a void pointer as an argument, like so: int func(void *p); How can we determine or guess the type of what p is pointing to? ...

c++ process always on foreground in window OS

I have a c++ process, I want that process should always remain on foreground, kindly guide me how can I make it possible? ...

Redirecting exec output to a buffer or file

I'm writing a C program where I fork(), exec(), and wait(). I'd like to take the output of the program I exec'ed to write it to file or buffer. For example, if I exec ls I want to write file1 file2 etc to buffer/file. I don't think there is a way to read stdout, so does that mean I have to use a pipe? Is there a general procedure he...

When binding a client TCP socket to a specific local port with Winsock, SO_REUSEADDR does not have any effect

I'm binding a client TCP socket to a specific local port. To handle the situation where the socket remains in TIME_WAIT state for some time, I use setsockopt() with SO_REUSEADDR on a socket. It works on Linux, but does not work on Windows, I get WSAEADDRINUSE on connect() call when the previous connection is still in TIME_WAIT. MSDN is...

Should I always include stddef.h if I use sizeof and size_t

Hi, if I'm using the sizeof operator and making use of size_t in my code, do I have necessarily have to include stddef.h? I haven't included stddef.h, and my code compiles without warning with both MVS2008 and with Borland C++ BuilderX. Thanks a lot... ...

What is a good project structure in C

Hi, I have been working in Java/J2ee projects, in which I follow the Maven structure. I want to develop [say a command line interpreter in linux {ubuntu}] in C. I never develop projects in C. I want to know what project structure I should follow. ...

How to implement B+ Tree for file systems ?

I have a text file which contains some info on extents about all the files in the file system, like below C:\Program Files\abcd.txt 12345 100 23456 200 C:\Program Files\bcde.txt 56789 50 26746 300 ... Now i have another binary which tries to find out about extents for all the files. Now currently i am using linear search to find extent ...

calloc v/s malloc and time efficiency

I've read with interest the post C difference between malloc and calloc. I'm using malloc in my code and would like to know what difference I'll have using calloc instead. My present (pseudo)code with malloc: Scenario 1 int main() { allocate large arrays with malloc INITIALIZE ALL ARRAY ELEMENTS TO ZERO for loop //say 100...

C stdout printf problem

I have a weird issue with printing data out. I use printf to print a char* string and then after that print another one. However part of the first string doesn't get printed and when I print the second string the missing part of the first one is pretended to that one. What is happening here? I'm writting a simple libpcap implimentatio...

Why should structure names have a typedef?

I have seen source codes always having a typedef for a structure and using the same everywhere instead of using the structure name as "struct sname" etc directly? What is the reason behind this? Are there any advantages in doing this? ...

char pointers & integer pointers (++)

i have two pointers, char *str1; int *str2; if i look at the size of both the pointers lets assume str1=4 bytes str2=4 bytes str1++ will increment by 1 byte but if str2++ will increment 4 byte could anybody tell e the concept behind this? ...