How to write log base(2) in c/c++
Is there any way to write log(base 2) function? the c language has 2 built in function -->> 1.log which is base e. 2.log10 base 10; But i need log function of base 2.How to calculate this.Someone help me. ...
Is there any way to write log(base 2) function? the c language has 2 built in function -->> 1.log which is base e. 2.log10 base 10; But i need log function of base 2.How to calculate this.Someone help me. ...
Ok, I know this question seems to have been asked many times on stackoverflow. but please read Well the answer for any address is "No you can't" but the question here is to know if a pointer points to a piece of memory allocated with malloc/new. Actually I think it could be easily implemented overriding malloc/free and keeping track of ...
Is there any way to get back the characters outputted into a variable on ncurses ? let's say I do: printw("test"); then I want to be able to: somefunc(strbuffer); printf("%s",strbuffer); // test I need a function to get back all characters on the screen into a variable, scr_dump get's close but the output format is unreadable.. ...
How can I do dataflow (pipes and filters, stream processing, flow based) in C? And not with UNIX pipes. I recently came across stream.py. Streams are iterables with a pipelining mechanism to enable data-flow programming and easy parallelization. The idea is to take the output of a function that turns an iterable into another it...
Hi, let's say I have code in C with approximately this structure: switch (something) { case 0: return "blah"; break; case 1: case 4: return "foo"; break; case 2: case 3: return "bar"; break; default: return "foobar"; break; } Now obviously, the "break"s are not necessary for the code to run correctly, but it sort of...
I have a piece of C code that is used from a C++ function. At the top of my C++ file I have the line: #include "prediction.h" In prediction.h I have this: #ifndef prediction #define prediction #include "structs.h" typedef struct { double estimation; double variance; } response; response runPrediction(int obs, lo...
I tried to compile the following library and everything went smooth until the last step. /* File : computation.c */ int add(int x, int y) { return x + y; } /* File: computation.i */ %module computation extern int add(int x, int y); $ swig -ruby computation.i $ gcc -c computation.c $ gcc -c computation_wrap.c -I/opt/local/lib/ruby/1....
I need to have a makefile work under DOS (Windows) and Cygwin. I having problems with the makefile detecting the OS correctly and setting appropriate variables. The objective is to set variables for the following commands, then invoke the commands in rules using the variables: Delete file: rm in Cygwin, del in DOS. Remove director...
Is there a Cocoa class has similar functionality to enumerated values from C? I know that I can just use enums in Cocoa, but what if I want to put an enum in an NSArray (which only accepts objects)? ...
In javascript I am used to just being able to pick any character from a string like "exm[2]" and it would return to me the third character in a string. In C is there a way to do that or something without a function that requires a buffer? ...
I needed to add AM_PATH_CHECK to configure.am I then try to run the usual sequence of autotools commands to rebuild all the makefiles and whatnot: aclocal automake -ac autoheader autoreconf ./configure make and here my lack of understanding of autotools showes up because this release of openssh has no Makefile.am??? now what do I do? ...
I'm trying to write an application that can be used to create pictures that look like paintings using simulated brush strokes. Are there any good sources for simple ways of simulating brush strokes? For example, given a list of mouse positions that the user has dragged the mouse through, a brush width and a brush texture, how do I determ...
While searching for Tutorials on generating random numbers in C I found This Topic When I try to use the rand() function with parameters, I always get the random number generated 0. When I try to use the rand() function with parameters, I always get the value 41. And whenever I try to use arc4random() and random() functions, I get a LN...
I've found myself limiting scope fairly often. I find it makes code much clearer, and allows me to reuse variables much more easily. This is especially handy in C where variables must be declared at the start of a new scope. Here is an example of what I mean. { int h = 0; foreach (var item in photos) { ...
How do I change the library a function loads from during run time? For example, say I want to replace the standard printf function with something new, I can write my own version and compile it into a shared library, then put "LD_PRELOAD=/my/library.so" in the environment before running my executable. But let's say that instead, I want ...
Good day everyone! I’m trying to understand how buffer overflow works. I’m doing this for my project in a computer security course I’m taking. Right now, I’m in the process of determining the address of the function’s return address which I’m supposed to change to perform a buffer overflow attack. I’ve written a simple program based from...
Hi, I am using C language and Linux as my programming platform. I am learning how to create a daemon, and I want to create a log file so that I write a debug message in my daemon. My question is where should I put the log file in my system. Should I put it in the var folder? Please advice. Many thanks. ...
For Example: If I need to read a multiple line input like(and I dont know How many lines would be there!!): 1 20 2 31 3 41 I am using something like int main() { string line; while(getline(cin,line) != NULL) { // some code // some code } } Now the program never stops- i.e always it expects some inpu...
Hi there, I am writing swig bindings for some c functions. One of these functions takes a float*. I am already using cpointer.i for the normal pointers and looked into carrays.i, but I did not find a way to declare a float*. What do you recommend? interface file: extern int read_data(const char *file,int *n_,int *m_,float **data_...
i use rrd (graphic programming ) under rrdtool, i have installed; and i rund gcc gcc -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -lrrd -o myprog test.c myprog is execute file and test.c ist testprogram who i use function rrd_create from libary but gcc put out error like this: /usr/bin/ld: cannot find -lrrd why!!!! ...