sizeof (int) == sizeof (void*) ?
Is there an integer type with the same size as pointer? Guaranteed on all microarchitectures? ...
Is there an integer type with the same size as pointer? Guaranteed on all microarchitectures? ...
In my numerical simulation I have code similar to the following snippet double x; do { x = /* some computation */; } while (x <= 0.0); /* some algorithm that requires x to be (precisely) larger than 0 */ With certain compilers (e.g. gcc) on certain platforms (e.g. linux, x87 math) it is possible that x is computed in higher than dou...
I need to draw an 2d-array of color triplets on the screen, what is the fastest way of doing that? The target language is C/C++ and the program has only to work on Linux, but platform independant solutions are preferred obviously. I run Xorg, XVideo and OpenGL are available. How many FPS can I expect on 1024x768 on an Intel Core 2 Duo ...
When calling execl(...) I get an errno=2. What does it mean ? How can I know the meaning of this errno ? ...
I am trying to figure out how to write a new line of text at the beginning of a file (a header). I know I can open the file, or seek to the beginning of a file, but if I write with that, it will overwrite what's there. Do I have to write a new file and then write the other data to it line by line, or is there a better way? Example file:...
I have a list of values such as "12000","12345","123456" that need to be converted to currency ("120.00", "123.45", "1234.56"). The only way I know is to convert the value to a string, copy the first strlen()-2 characters to one string (dollars) and the remainging two digits to another string(cents) and then write them as the following: ...
I am attempting to seek in a movie using ffmpeg's av_seek_frame method however I'm having the most trouble determining how to generate a time-stamp to seek to. Assuming I want to seek x amount of frames either forward or backward and I know what frame the movie is currently on, how would I go about doing this? ...
In a C project (POSIX), how do I get the fully qualified name for the current system? For example, I can get just the hostname of my machine by doing gethostname() from unistd.h. This might give me machine3 in return, but I'm actually looking for machine3.somedomain.com for example. How do I go about getting this information? I do not ...
Is it safe and predictable to reuse pointers after freeing the data they point to? For example: char* fileNames[] = { "words.txt", "moreWords.txt" }; char** words = NULL; int* wordsCount = NULL; for ( i = 0; i < 2; ++i ) { data = fopen( fileNames[i], "r" ); words = readWords( data ); wordsCount = countWords( words ); f...
I'm trying to read/write to a FM24CL64-GTR FRAM chip that is connected over a I2C bus on address 0b 1010 011. When I'm trying to write 3 bytes (data address 2 bytes, + data one byte), I get a kernel message ([12406.360000] i2c-adapter i2c-0: sendbytes: NAK bailout.), as well as the write returns != 3. See code below: #include <linux/i...
Write a program that sums the sequence of integers as well as the smallest in the sequence. Assume that the first integer read with scanf specifies the number of values remaining to be entered. For example the sequence entered: Input: 5 100 350 400 550 678 Output: The sum of the sequence of integers is: 2078 ...
Hi all. I'm lookin for a portable wiimote library. I want to use the wiimote for the hardware it has (but I don't need to access any data stored on it). Required features: access to all the buttons (as an exception, no use of the power button is OK) make the wiimote play sound talk to nunchuks and classic controllers preferably: mak...
Consider the following test program: static void func(int a) { } int main() { unsigned int b = 42; func(b); return 0; } Compiling it with gcc: lol@mac:~/projects$ gcc -Wconversion testit.c testit.c: In function âmainâ: testit.c:11: warning: passing argument 1 of âfuncâ as signed due to prototype lol@mac:~/projects$ ...
How can i have a pointer to the next struct in the definition of this struct? : typedef struct A { int a; int b; A* next; } A; this is how i first wrote it but it does not work. ...
As a big fan of Charles Petzold's books Code and The Annotated Turing I came across his book Programming Windows which teaches Win32 programming in C. I am a freshman computer science student who learned C first, but I use C# and .NET for Windows programming now, so I was wondering if Win32 is still relevant to professional Windows progr...
I need to convert a char array into int and float using C The array is like this char* text = "15.34"; I also need to convert a float/int back into an array again ...
I opened a file stream to a very big file using fopen. Before performing any read operation on that stream, I deleted the file using unlink(). And still, I was able to read the whole file. I am guessing that there is a buffer associated with the stream, which holds the data of the file. But obviously that buffer will have a limit. That ...
pyPdf is a great library to split, merge PDF files. I'm using it to split pdf documents into 1 page documents. pyPdf is pure python and spends quite a lot of time in the _sweepIndirectReferences() method of the PdfFileWriter object when saving the extracted page. I need something with better performance. I've tried using multi-threading...
Hey all, I'm on Ubuntu Intrepid and I'm using jpeglib62 6b-14. I was working on some code, which only gave a black screen with some garbled output at the top when I tried to run it. After a few hours of debugging I got it down to pretty much the JPEG base, so I took the example code, wrote a little piece of code around it and the output...
I am considering porting a small portion of the code in a C# project of mine to C/ASM for performance benefits. (This section of code uses many bitwise operations and is one of the few places where there may exist a real performance increase by using native code.) I then plan to simply call the native function in the separate DLL via P/I...