The manpage for the POSIX binary tree functions includes the following statements:
tdelete() returns a pointer to the parent of the item deleted, or NULL if the item was not found.
tdelete() frees the memory required for the node in the tree. The user
is responsible for freeing the memory for the corresponding data.
...
I am currently working on a project about setting process to one core in linux environment. I use sched_setaffinity to do this job and I wonder whether there are some functions provided by linux to get which core the process is running on. I use top command and find it could get this info using j option. So i am sure there are some wa...
i'm trying to get some number of bytes from source using libcurl by setting:
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 100); //get 100 bytes from source
But I get different size of data each time, not even close sometimes only 22 bytes. does this work?
...
There is a directory where a buddy adds new builds of a product.
The listing looks like this
$ ls path-to-dir/
01
02
03
04
$
where the numbers listed are not files but names of directories containing the builds.
I have to manually go and check every time whether there is a new build or not. I am looking for a way to automate this, s...
Hello,
gcc 4.4.4 c89
I am keep getting a "Cannot dereference to incomplete type".
However, I am sure I have my structure type complete. I return the Network_t instance that is the pointer to the allocated memory. I should be able to dereference that memory.
Many thanks for any advice,
I have this in my header file:
driver.h
typedef...
When compiling a program containing this particular function,
/*
* Function read_integer
*
* @Parameter CHAR* stringInt
*
* Parameter contains a string representing a struct integer.
* Tokenizes the string by each character, converts each char
* into an integer, and constructs a backwards linked list out
* of the digits.
*
* @...
It seems uninitialized global variable is treated as weak symbol in Gcc. What is the reason behind this?
...
I have some knowledge in C/C++ but only using the Console. I'd like to start programming some graphical interfaces, but I don't have the minimal idea where to start.
I've heard of GUI applications and DirectX applications. I'd like to know which is the best for start programming?
Which libraries also is good to use and some tutorials...
The following program shows that we can use return() or pthread_exit() to return a void* variable that is available to pthread_join()'s status variable.
(1) Should there be a preference for using one over the other?
(2) Why does using return() work? Normally we think of return putting a value on the stack but since the thread is comple...
I am working on a CPU-heavy numerical computation app. Without going into many details, it's a computational math research project that involves computing a certain function f(x) for large integer x.
Right now everything is implemented in C++ in x64 mode, using native 64-bit ints. That limits me to x<2^64~1.8*10^19. I want to go furthe...
I'm trying to implement the Diamond-square algorithm, but the problem is only part of the bitmap is being filled and I'm not sure what's wrong. I'm doing it recursively:
GLuint CreateDsquare()
{
std::vector<GLubyte> pdata(256 * 256 * 4);
vector2i loc;
vector2i sz;
GLubyte val;
sz.x = 25...
I was reading the paper "Garbage Collector in an Uncooperative Environment" and wondering how hard it would be to implement it. The paper describes a need to collect all addresses from the processor (in addition to the stack). The stack part seems intuitive. Is there any way to collect addresses from the registers other than enumeratin...
Floating point type represents a number by storing its significant digits and its exponent separately on separate binary words so it fits in 16, 32, 64 or 128 bits.
Fixed point type stores numbers with 2 words, one representing the integer part, another representing the part past the radix, in negative exponents, 2^-1, 2^-2, 2^-3, etc.
...
I have a particular function (well, set of functions) that I want to start every 400ms. I'm not much of a C programmer, and so anything outside of the standard libraries is a mystery to me, as well as quite a bit within them.
My first thought is to use nanosleep to pause execution for 400ms in some sort of loop, but this of course doesn...
I'm writing a simple shell as an OS course assignment, I need to search in the PATH to find the program user typed in, once I find the right directory, I malloc a piece of memory just enough to hold the directory name plus the program name, and I pass it as the first argument to execv().
I could have statically allocated 100 characters ...
I am working on a personal learning project to make a Minecraft clone. It is working very well aside from one thing. Similar to Minecraft, my terrain has lots of cubes stacked on the Y so you can dig down. Although I do frustum culling, this still means that I uselessly draw all the layers of cubes below me. The cubes are X, Y and Z orde...
In C99 there are variable-length arrays, and there can be static qualifiers (and type qualifiers) in parameter array declarators:
void f(int i, int *a);
void f(int i, int a[]);
void f(int i, int a[i]);
void f(int i, int a[*]); // Only allowed in function prototypes.
void f(int i, int a[static i]);
Since array function paramete...
Does anyone know why there is no snwprintf function in the C standard library?
I am aware of swprintf, but that doesn't have the same semantics of a true, wchar_t version of snprintf. As far as I can tell, there is no easy way to implement an snwprintf function using [v]swprintf:
Unlike snprintf, swprintf does not return the necessary...
I am doing my project to implement a typing tutor application in turbo C compiler
(this is the limit), this function is actually a look up table for x,y and key character but it is returning a garbage value at first value of that I passed in argument.
From second onwards it starts doing right.
Note that that x,y are pointers to return tw...
I'm having difficulty figuring out how to use rand() and seeding it with time() using Xcode. I want to generate random decimal numbers between 0 and 1.
The code gives me seemingly random numbers for elements 1 and 2, but element 0 is always somewhere around 0.077. Any ideas why this would be?
My code is:
#include <stdio.h>
#include <s...