How do I measure time in C?
I want to find out for how long (approximately) some block of code executes. Something like this: startStopwatch(); // do some calculations stopStopwatch(); printf("%lf", timeMesuredInSeconds); How? ...
I want to find out for how long (approximately) some block of code executes. Something like this: startStopwatch(); // do some calculations stopStopwatch(); printf("%lf", timeMesuredInSeconds); How? ...
if i have long long number with zeros before the number like this 0x000000000076fba1 how do i print the number with all the zeros? cuse when i tried to print the numb its writs 0x76fba1. thank you! ...
Hi All, I want to use dll from ssdeep (http://ssdeep.sourceforge.net/). The API is: int fuzzy_hash_buf(unsigned char *buf, uint32_t buf_len, char *result); then in Delphi, i write it like this: function fuzzy_hash_buf(buf : Pbyte; buf_len : Cardinal; result : PAnsiChar): integer; stdcall; external 'fuzzy.dll' name 'fuzzy_hash_buf'; ...
I implemented a function called abs(). I get this error: Intrinsic function, cannot be defined What have I done wrong? I'm using Visual Studio 2005. ...
Possible Duplicate: Is there a performance difference between i++ and ++i in C++? In terms of usage of the following, please rate in terms of execution time in C. In some interviews i was asked which shall i use among these variations and why. a++ ++a a=a+1 a+=1 ...
Hello super-intelligent people! Thanks so much for checking out my post. Right now I'm running this: NSTask *task; task = [[NSTask alloc] init]; [task setLaunchPath: @"/usr/bin/top"]; NSArray *arguments; arguments = [NSArray arrayWithObjects: @"-stats", @"pid,cpu", nil]; [task setArguments: arguments]; NSPipe *pipe; pipe = [NSPipe ...
Mapping signed to unsigned integers bijectively can be done using common techniques like Two's complement. Unfortunately, they fail to map small negative integers to small numbers. For compression algorithms, we often want to preserve the absolute value of numbers as much as possible: small negative and positive numbers must be mapped to...
I am aware of the 2s complement representation of signed values. But how does binary '10000000' become -128 in decimal(using %d). for +64 binary rep = '01000000' for -64 binary rep = '11000000' which is 2's complement of '01000000' can some one please explain? Program: int main() { char ch = 1; int count = 0; while(count !=...
I have a C array called buf. Here is it's definition: char buf[1024]; Now, my current code takes from stdin and uses fgets() to set that array, however I wish to use code to set it instead. Right now the line that sets buf looks like this: fgets(buf, 1024, stdin); Basically, I want to replace stdin, with say... "My String". What's th...
Hi , i'm about to port very large scale application to 64 Bits, i've noticed in that in the web there some articles which shows many pitfalls of this porting , i wondered if there is any tool which can assist in porting to 64 bit , meaning finding the places in code that needs to be changed.... maybe the gcc with warnnings enabled.....
I have a process that feeds a piece of hardware (data transmission device) with a specific buffer size. What can I reasonable expect from the windows scheduler windows to ensure I do not get a buffer underflow? My buffer is 32K in size and gets consumed at ~800k bytes per second. If I fill it in 16k byte batches that is one batch every...
I have some code that uses libgmp. At some point the user may request a factorial of a very large number. Unfortunately, this results in libgmp raising an abort signal. For example the following code: #include <cmath> #include <gmp.h> #include <iostream> int main() { mpz_t result; mpz_init(result); mpz_fac_ui(result, 209...
I have an ANSI C program that dynamically loads a .so file using dlopen() passing RTLD_LAZY. I receive Undefined symbol "_nss_cache_cycle_prevention_function" warnings whenever the .so file is accessed in FreeBSD 7.2. nss_cache_cycle_prevention_function() is not one of my program's functions and I imagine must be coming from FreeBSD....
How do I use pow() and sqrt() function in Ubuntu? I have included the math.h header file but it still gives me an error. ...
Hi folks, I am aware of various switch case opimization techniques, but as per my understanding most of the modern compilers do not care about how you write switch cases, they optimize them anyway. Here is the issue: void func( int num) set = 1,2,3,4,6,7,8,10,11,15 { if (num is not from set ) regular_action(); else ...
When I call pthread_exit from main, the program never gets to terminate. I expected the program to finish, since I was exiting the program's only thread, but it doesn't work. It seems hung. #include <stdio.h> #include <stdlib.h> #include <pthread.h> int main(int argc, char *argv[]) { printf("-one-\n"); pthread_exit(NULL); ...
I've seen a lot of the following in older C code: type_t *x = (type_t *) malloc(...); What's the point of casting the pointer returned from malloc() since it's void *? Is it because older C compilers didn't support void pointers and malloc() used to return char * instead? ...
I have never programmed in C and have not programmed in C++ for a little while and either way, I am still learning. I am writing a program in C and am converting a MATLAB program to this C program. I have a lot of variables from MATLAB that are cartesian coordinates, X Y Z, of points. Is there a variable type I could use built into C? I...
I know very little about OOP, so maybe my question is silly, but still.... Can you access object-oriented (OO) API from procedural (non-OO) languages? For example, Win32 API is not OO, but I know there is a wrapper for C++ to make it OO. But is it possible to do it both ways? I ask because I don't like OO languages; I learned C by prog...
Okay, strange question time! I'm refactoring some old C++ code that declares a bunch of arrays like so: static SomeStruct SomeStructArray[] = { {1, 2, 3}, {4, 5, 6}, {NULL, 0, 0} } And so forth. These are scattered about in the source files, and are used right where they're declared. However, I would like to move them in...