c

Can't understand this conversion from C to Assembly....

Hi, I'd like to know if someone can explain me the solution to this problem: the code is: #include <stdio.h> #include <stdlib.h> typedef struct { int c[20]; int n; } t_coda; t_coda coda; void init(t_coda *coda) { coda->n = 0; } void add(t_coda *coda, int x) { if (coda->n < 20) coda->c[(coda->n)++] = ...

i am out of ideas...

i have an assignment,and i need help!! in a given 2D ARRAY of integers and a given MAXIMUM number of steps the program supposed to find a path, from one corner to the one in front of it, which sums the biggest numbers in limited number of steps. this supposed to be done with BACKTRACKING RECURTION... ...

Linux, timerfd accuracy

I have a system that needs at least 10 mseconds of accuracy for timers. I went for timerfd as it suits me perfectly, but found that even for times up to 15 milliseconds it is not accurate at all, either that or I don't understand how it works. The times I have measured were up to 21 mseconds on a 10 mseconds timer. I have put together...

Using random numbers with GPUs

I'm investigating using nvidia GPUs for Monte-Carlo simulations. However, I would like to use the gsl random number generators and also a parallel random number generator such as SPRNG. Does anyone know if this is possible? Update I've played about with RNG using GPUs. At present there isn't a nice solution. The Mersenne Twister that c...

Can gcc generate different size object code ?

Which option should be enabled in gcc to generate 16-bit or 32-bit or 64-bit object code ? Are there separate options for generating each of the above object code type ? ...

Algorithms that can take an N length string and return a fixed size unique value?

I'm looking to add basic licensing to my application. I want to take in the user's name as a parameter and return a unique, fixed length code (sort of like MD5) What are some algorithms that can do this? Thanks ...

Why use select() instead of sleep()?

I'm working through a chapter about iPhone audio and have come across a section of code that I can't make sense of: while (aqc.playPtr < aqc.sampleLen) { select(NULL, NULL, NULL, NULL, 1.0); } (Full code sample is on pages 163-166). From what I understand of the code the audio is being processed on another thread and the while lo...

Allocate executable ram in c on linux

I want to make a simple just-in-time compiler with c on Linux. How can I allocate memory such that I can write out raw x86 code to it and execute it as any other function? ...

What is the most efficient way to print a file in C to stdout?

I'm stuck on this. Currently I'm using: FILE *a = fopen("sample.txt", "r"); int n; while ((n = fgetc(a)) != EOF) { putchar(n); } However this method seems to be a bit inefficient. Is there any better way? I tried using fgets: char *s; fgets(s, 600, a); puts(s); There's one thing I find wrong about this second method, which is tha...

Writing a structure all at once in a file

I'm doing a school project about maintaining a personal Database. but my tutors didn't explained the practice, they explained the theory(Data structures and such) not how to code in c. We where given a certain amount of tables, indexes and consults they wanted to solved and we are to program the data structures that run behind. I ch...

Exploring Virtual Memory (ProcessWalker)

I was reading this article on MSDN "Managing Heap Memory in Win32" And in it they are explaining about a tool called ProcessWalker.exe In the article they explained that they can use this tool to explore the contents of virtual memory of any process. Does anyone know where I can download this tool from. Or maybe ProcessWalker might b...

In C, is it necessary to free a pointer at exit?

Possible Duplicate: When you exit a C application, is the malloc-ed memory automatically freed? In C, is it necessary to free a pointer at exit? When the program exists, does it free memory from pointers still pointing to an allocated block? Is it dependent on the OS? ...

Getting text from tab control item is failing

I'm trying to get the text from a tab control like this: TCITEM itm; itm.mask = TCIF_TEXT; TabCtrl_GetItem(engineGL.controls.MainGlTab.MainTabHwnd,i,&itm); but the psztext part of the structure is returning a bad pointer (0xcccccccccc). I create the tabs like this: void OGLMAINTAB::AddTab( char *name ) { TCITEM ...

Linker issue calling the D3DX10CreateEffectFromFile() method

Having issues trying to retrieve a effect file for directX. If I do not include the D3DX10CreateEffectFromFile() method, the application compiles correctly. If I do include it. I get the following error 1>GXDX.obj : error LNK2019: unresolved external symbol _D3DX10CreateEffectFromFileW@48 referenced in function "public: virtual void __...

How can I reverse-map (hash) `pthread_t`s to structure pointers?

I have a thread datatype in the interpreter implementation for a programming language I am working on. For various reasons, it’s a fairly common operation, to need to get the current thread (which is, itself, a pointer: a struct thread*). However, pthread_self(3) hands me a pthread_t, which is an opaque type; on some systems, it seems t...

g_io_scheduler_job_send_to_mainloop problem

Hello, I have foowing code fo runing function in another thread: void load (....) { GIOSchedulerJob *job; g_io_scheduler_job_send_to_mainloop(job,(GSourceFunc)job_func,&param, g_free); } gboolean job_func(GIOSchedulerJob *job, GSourceFunc func, gpointer user_data, GDestroyNotify notify) { JobParam* job_p...

integer type long and division

Hi all, I just write a procedure to decompose an unsigned integer to prime numbers. it will work normally if I define the data type as "int", if I change it to "long", result will be wrong. I don't know why. BTW, I used Win-TC as my compiler. Code as below: #include "stdio.h" #define True 0xff #define False 0x00 char DividerIsPr...

return result of system function in char*

Hello Suppose I do a system("ps-C nautilus"); how do I return the result of this function in char* ? Thank you. ...

Suggest user-mode filesystem filter framework plz

I need a user-mode filesystem filter (not virtual filesystem). One of such frameworks is http://eldos.com/cbflt/, but it has some bugs and I need an alternative. Suggest similar frameworks. ...

C programming - Breaking down of money

I need to break down the amounts on their respective bill/coin. The output is somewhat like this: So far, here is my code: (I made the last few codes a comment one 'cos the errors come from there) { int x,y; printf("Enter input: "); scanf("%d",&x); y=x/1000; printf("\n# of $1000 bill: %d",y); x = x%1000; y=x/500; ...