c

Are cores (device abstraction level) of OSs written entirely in C? (Like: "UNIX is written in C")

Are cores of OSs (device interaction level) really written in C, or "written in C" means that only most part of OS is written in C and interaction with devices is written in asm? Why I ask that: If core is written in asm - it can't be cross-platform. If it is written is C - I can't imagine how it could be written in C. OK. And what ...

Is there a standard way of representing an SHA1 hash as a C string, and how do I convert to it?

This question is about how to create an SHA-1 hash from an array of data in C using the OpenSSL library. It returns an array of 20 bytes, containing the hash. Is there some standard way of representing that data in string form, not binary? If so, is there a function in OpenSSL itself to convert to said string format? If not, how shoul...

win32 api - how to check for user privileges on a remote machine

given user credentials to either a local account on a remote machine or a domain account, how can i check the user privileges these credentials grant on a remote host ? i can lookup the SID for the account, but how do i know if, for instance, this account is a members of the administrators group on the remote host ? i can find plenty o...

Is rebasing DLLs (or providing an appropriate default load address) worth the trouble?

Rebasing a DLL means to fix up the DLL such, that it's preferred load adress is the load address that the Loader is actually able to load the DLL at. This can either be achieved by a tool such as Rebase.exe or by specifying default load addresses for all your (own) dlls so that they "fit" in your executable process. The whole point of ...

How extract meaningful text from HTML

Hi I would like to parse a html page and extract the meaningful text from it. Anyone knows some good algorithms to do this? I develop my applications on Rails, but I think ruby is a bit slow in this, so I think if exists some good library in c for this it would be appropriate. Thanks!! PD: Please do not recommend anything with java ...

Are there any platforms that do not support reentrent mutex's or recursive locks?

I'm wondering if my implementation should expect that reentrant mutex's are supported or not. The code is supposed to portable/platform independent. I'm wondering if mutex recursion is common enough that it shouldn't be a concern. ...

Exception handling in pure C

Possible Duplicate: C : How do you simulate an 'exception' ? Hi, I know that exception handling is available in C++ but not in C. But I also read that exception handling is provided from OS side, so isnt there any function for C invoking the same behavior from OS as try catch and throw? Thanks. ...

How To Store Values In Non-Contiguous Memory Locations With SSE Intrinsics?

I'm very new to SSE and have optimized a section of code using intrinsics. I'm pleased with the operation itself, but I'm looking for a better way to write the result. The results end up in three _m128i variables. What I'm trying to do is store specific bytes from the result values to non-contiguous memory locations. I'm currently doin...

Using getchar() on c gets the 'Enter' after input

I'm trying to write a simple program that asks a user to choose from a menu in a loop. I use getchar() to get the input, however i've noticed that when I enter a char and press 'Enter' the program makes two loops (as if i pressed twice) one the char as an input and another for 'Enter' as an input. How do I fix this? Thanx. ...

print only number,why it output so weird?

char* fun(char *s) { char buffer[50]; int i=0; while(*s){ if(isdigit(*s)){ buffer[i++]=*s; } s++; } buffer[i]='\0'; return buffer; } int main(){ char *s="o34"; char *p="off"; p=fun(s); while(*p){ printf("%c",p); p++; } //printf("%s",fun(&s[0])); //puts(fun(s)); getchar(); } ...

Fedora Equivalent of prstat /truss

Is there any command in Fedora core (10) which displays the system call being executed ? Scouring the internet only reveals top and likes... ...

Neural Networks: Minimal, open source example with exhaustive training data?

Hello forum, I am currently searching for a neural network (toy) example, that I might optimize using GPU kernels. I need clean & minimal code (no fancy optimizations, max. a few thousand sloc) ample testing data C/C++ open source Does anybody has an adequate hint? There's a bunch of examples on the net, but with insufficient test...

C (beginner) : Why won't my qsort work? EDIT: From one error to another

I'm doing K&R exercise 6-4, which is: 6-4. Write a program that prints the distinct words in its input sorted into decreasing order of frequency of occurrence. Precede each word by its count. What I decided to do is create a struct called dstncFreqNode6_4: struct dstncFreqNode6_4 { char *word; int count; struct dstncFreqN...

#define vs. enums for addressing peripherals

I have to program peripheral registers in an ARM9-based microcontroller. For instance, for the USART, I store the relevant memory addresses in an enum: enum USART { US_BASE = (int) 0xFFFC4000, US_BRGR = US_BASE + 0x16, //... }; Then, I use pointers in a function to initialize the registers: void init_usart (void) { v...

cleaning all characters from terminal

void clearscreen ( void ) { char a = 'a' ; fflush ( stdout ); do{ a = getc( stdin ) ; if ( isspace ( (int ) a ) ) { getc ( stdin ); } }while ( a != EOF ); } I want write functi...

Why doesn't this compile in C18?

I'm trying to compile the following code using the MPLAB C18 v3.36 compiler. Compiler returns a syntax error on 'char rij;'. But when i put char rij; a line earlier (before TRISA = ...), it compiles ... void setup(void) { TRISD = 0b00000000; TRISA = 0b00000000; char rij; for (rij = 0; rij<ROWS; rij++) { red_byte_array[rij]=0; g...

problem with a kbhit implementation

This is the kbhit implementation that I found, but for some reason it just waits a key to be pressed instead of returning some result other than 0. It doesn't really function as kbhit... int kbhit(void) { struct timeval tv; fd_set read_fd; tv.tv_sec=0; tv.tv_usec=0; FD_ZERO(&read_fd); FD_SET(0,&read_fd); if...

How does a bit field work with character types?

struct stats { char top : 1; char bottom : 1; char side : 2; } MyStat; I have seen this format with integers but how does the above char bit field work and what does it represent? Thank You. ...

GDB Quirks with Thread Process

I am debugging a process with multiple threads in GDB. I compiled the sole source file with the -g flag. However, while running in GDB, the following scenario occurs: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7fe2b70 (LWP 2604)] 0x00000011 in ?? () Prior to the switch, the particular thread executes...

Possible Stack Corruption

With reference to my previous question about GDB not pinpointing the SIGSEGV point, My thread code is as follows: void *runner(void *unused) { do { sem_wait(&x); ... if(/*condition 1 check*/) { sem_post(&x); sleep(5); sem_wait(&x); if(/*repeat condition 1 check; after atleast 5 seconds*/) { printf("LEAVING....