Does anyone know to get the current thread ID as an integer on BSD?
i found this
#ifdef RTHREADS
299 STD { pid_t sys_getthrid(void); }
300 STD { int sys_thrsleep(void *ident, int timeout, void *lock); }
301 STD { int sys_thrwakeup(void *ident, int n); }
302 STD { int sys_threxit(int rval); }
30...
I couldn't find another topic about this. I apologize if it's a duplicate.
So, what feature do you miss in the C language?
Please, keep in mind the design principles (Trust the programmer, Keep the language small and simple, Provide only one way to do an operation, etc..) so don't come out with "Garbage collection would be awesome!...
Not so long ago I've installed Debian and configured it with my friend's help.
Yesterday I have downloaded GCC 4.4 and I created a simple program to test it out.
This is the code:
#include <stdio.h>
int main () {
int result;
printf ("Hello Wor... Linux! This is my %dst program compiled in Debian.\nHow many is 2+2?\n", 1);
s...
Suppose I have a function
void foo(char *)
which, internally, needs to treat its input as a block of NUL-terminated bytes (say, it's a hash function on strings). I could cast the argument to unsigned char* in the function. I could also change the declaration to
void foo(unsigned char *)
Now, given that char, signed char and unsigne...
I'm writing a application that put docks in the right side of the screen, like this:
I can reserve space in the side of the screen by using the _NET_WM_STRUT_PARTIAL, so that the maximized windows won't overlap the docks.
In the image, you can see that there is a top panel. The problem is that the docks will overlap the panel. Is the...
I'm having some trouble figuring out how to generate the cartesian product of a jagged array. I have googled around, but i cant seem to find an implentation for a iterative language. So i'm trying to figure it out myself, but i've hit a snag. Lets define the problem a bit clearer
Say i have an array of arrays which looks like this
A = ...
Hi,
I'm trying to encode and transfer raw video frames over LAN (100 Mbps) connection (frames captured by a web cam). What video/image encoding format is recommended for fast compression (with not much regard for the compression ratio) ?
Thanks,
...
How can I understand the parsing of expressions like
a = b+++++b---c--;
in C?
I just made up the expression above, and yes, I can check the results using any compiler, but what I want to know is the ground rule that I should know to understand the parsing of such expressions in C.
...
For instance if I called WriteFile to the end of a file, and later I wanted to delete the written bytes, how could I do this? Do I have to read the file's contents into a buffer, re-create the file, and write the desired bytes, or is there an easier way?
...
I have having some trouble printing a "char" from an ASCII value stored in an array.
The goal overall is to read a string of input from the user, store that in an array. Then use another array to count the number of times each character appears in the string, storing the number of occurances in the array address that matches the ASCII c...
I have a problem regarding static variables. It is said that the life of the static variable is beyond the bounds of the function (if defined in a function). But a pointer to it must give the value if it exits. But it does not work.
#include<stdio.h>
int *p;
int main()
{
clrscr();
test();
printf("%d",*p);
return 0;
}
vo...
This code is supposed to skip white space and return one word at a time. A couple of questions on this code: When the code gets to the *word++=c; line I get a core dump. Have I written this line correctly? and is return correct. And Do I need to somehow allocate memory to store the word?
//get_word
int get_word(char *word,int lim){
...
I have a custom boot loader that I would like to write to a .VHD file for testing. Any idea at what offset in the file I should write the boot loader to? Any pointers to the C structures for the .VHD file format?
...
Hey!
How can you compare against multiple possibilities in one argument?
Example:
if ((integer == 2) || (integer == 5))
if ((string == "hello") || (string == "dolly))
Would save me a lot of code if you could write that like this:
if (integer == (2 || 5))
if (string == ("hello" || "dolly"))
...
I read that Left shift e1<
x=5;
printf("%d",x<<3);
Output is 40 but according to me it should be 30.
and for x<<4 it is 80 .(but expected 40).
Although for x<<1 and x<<2 outputs are 10 and 20 as expected.Please explain this logic.
...
this is my struct :
struct Node {
struct Node* data;
struct Node* links[4];
}
assuming there is no padding, does Node->links[-1] guaranteed to be pointing on Node::data ?
...
I am always getting no bytes sent, with an errno of 22 (Invalid Argument) with this code. The destination_host is set elsewhere and known to be valid, so I really don't see what is going on. MAXMSGSIZE is 1000. No errors, or warnings. I am compiling with -Wall -Werror -pedantic
char *data_rec;
u_int data_len;
int sockfd;
uint16_t *...
mWhile attempting to make a backup copy of a file in C, I find that extra characters are sometimes generated by the algorithm below. I've also tried declaring the readBuffer within the while loop, but that did not solve the problem. Here's an example of the issue.
Original File Contents
Hello there.
My name is Alice.
Done.
Backup F...
I am working on a C assignment for uni, and I've been coding in TextMate and compiling in the command line.
But TextMate wont (or cant) format C code, as it would for say, HTML, Ruby or PHP (using SHIFT + CTRL + F).
Is there a plugin or some other tool I can use to fix my indenting and curly braces for .c files?
...
Hi guys,
How do you convert a uint8_t to a uint16_t?
currently im breaking down uint16_t to uint8_t like this:
packetBuffer.header[0] = ((co2Val>>8) & 0xff);
packetBuffer.header[1] = (co2Val & 0xff);
packetBuffer.header[2] = ((humVal>>8)&0xff);
packetBuffer.header[3] = (humVal & 0xff);
packetBuffer.header[4] = ((tem...