c

Automatic passing of argument by reference in C

I'm writing a Unicode library for C as a personal exercise. Without the actual code, I have this: typedef struct string { unsigned long length; unsigned *data; } string; // really simple stuff string *upush(string *s, unsigned c) { ... } // UTF-8 conversion string *ctou(char *old) { ... } char *utoc(string *old) { ... } u...

what is the meaning of qualifier?

what is the meaning of qualifier and difference between qualifier and keyword? as Volatile qualifier in C and we can say volatile is keyword so waht is the meaning of qualifier? ...

Runing a FIFO Simulation

I am trying to run a simulation program to test the FIFO alogarithm, howerver my program is just crashing. this is the main, other functions not shown. Can anyone spot for me the problem.Am not so familiar with using the main Argument[ int main(int argc, char *argv[])] I have the testing files in a folder int main(int argc, char *argv[]...

Keeping memory usage within available amount

I'm writing a program (a theorem prover as it happens) whose memory requirement is "as much as possible, please"; that is, it can always do better by using more memory, for practical purposes without upper bound, so what it actually needs to do is use just as much memory as is available, no more and no less. I can figure out how to prior...

Howto compute the factorial of x

how to get the value of an integer x, indicated by x!, it is the product of the numbers 1 to x. Example: 5! 1x2x3x4x5 = 120. int a , b = 1, c = 1, d = 1; printf("geheel getal x = "); scanf("%d", &a); printf("%d! = ", a); for(b = 1; b <= a; b++) { printf("%d x ", c); c++; d = d*a; } printf(" = %d", d); ...

a c program to add two singly linked lists, of unequal lengths containing single digited numbers in all of their nodes

i got this as an interview question. i was given 2 linked lists of unequal lengths,containing a single digited number in each of their nodes. i was asked to build a 3rd linked list which contains the sum of the two linked lists, again in the form of 1 digit in a node. ex: linked list 1 is 4-7-9-6 linked list 2 is 5-7 then the 3rd linked ...

How to get the modified environmental variables using c programme in Mac using bash terminal

Hi, I want to get the modified environment variables using C programme in Mac using bash terminal how to get it? if i use getenv i will get only the default system defined environment variables but i am not getting the modified one. how to get it ...

Declare a struct with zero values instead of random memory?

I have a struct like this: typedef struct string { unsigned long length; unsigned *data; } string; Can I write something so that when I do this: string s; the length property is zero, instead of whatever happens to be in the memory? data works well, as it's preset to zero or a null pointer. Example of what happens right now: st...

write a c function that generates one random number, or a pair of random numbers, or a triplet of random numbers given the particular ranges.

i have to generate random numbers for 3 different cases. i. 1 dice ii. a pair of dice iii. 3 dices my questions: 1. please suggest me sm good logic to generate random numbers for all the 3 cases. 2. does the logic change when i consider the cses of 2 dices, rather than 1? 3.how much of an effect does the range in which we have to genrate...

sorting the linked list

I am trying to make a function that sorts the linked list,which sorts the list by names. struct student { char name[50]; int roll_no; struct student *ptr_next; }*ptr_this,*ptr_first;/*ptr first points to first pointer */ void SortRecord(void) { struct student *out,*in,*temp; for(out=ptr_first;out!=(struct student*)NULL;out=out...

Using graphics hardware for audio processing in iphone app

We are developing an iphone app that needs to process audio data in real time, but we are suffering with performance. The bottlenecks are in audio effects, which are in fact quite simple, but the performance hit is noticeable when several are added. Most of the audio effects code is written in C. We think there are two places we can us...

What's a canonical example of code kata to learn about pointers ?

I've never worked with a language that didn't provide for some form of memory management, and thus managed to get by without ever really groking pointers. I can dabble in C I guess, as a result of coding in Objective-C for a little while. ...

Fast logistic function

I am looking for a way to implement a fast logistic function. The classic definition of logistic function is: y(x) = 1 / (1 + (1/e^x)) where ^ is exponentiation. or equally: y(x) = (e^x) / (e^x + 1) However, my special logistic function has a base E instead of e, so: y(x) = E^x / (E^x + 1) E and x in my case are 32-bit integer, fix...

C GetTickCount (windows function) to Time (nanoseconds)

Hello guys, I'm testing one code provided from my colleague and I need to measure the time of execution of one routine than performs a context switch (of threads). What's the best choice to measure the time? I know that is available High Resolution Timers like, QueryPerformanceCounter QueryPerformanceFrequency but how can I translate...

C vector as char *** vector

A function I need to use requires a vector argument for return storage with the following signature: char ***vvar What am I supposed to pass in there? How do I access elements afterward? ...

UTF-16 decoder not working as expected

I have a part of my Unicode library that decodes UTF-16 into raw Unicode code points. However, it isn't working as expected. Here's the relevant part of the code (omitting UTF-8 and string manipulation stuff): typedef struct string { unsigned long length; unsigned *data; } string; string *upush(string *s, unsigned c) { if ...

C struct static

Hi! I look through a C source (pjsip) and I find this sctucture. I don't know how to conceive. static struct user_agent { pjsip_module mod; pj_pool_t *pool; pjsip_endpoint *endpt; pj_mutex_t *mutex; pj_hash_table_t *dlg_table; pjsip_ua_init_param param; struct dlg_set free_dlgset_nodes; }...

How to count identifiers, no. of inputs and outputs in a Java program

I want to take a program as input and I want to find out: No. of identifiers No. of unique lines containing identifiers No. of identifiers in the set of unique lines No. of inputs and outputs According to control structures in the program I want to assign a value to control structures If I calculate this I can do my project. This is ...

UTF-8 decoder fails on non-ASCII characters

Note: if you've followed my recent questions, you'll see that they're all about my Unicode library exercise in C -- as one of my first few serious projects in C, I'm having many problems, so I'm sorry if I'm asking too many questions about one thing. Part of my library decodes UTF-8 encoded char pointers into raw unsigned code points. H...

64-bit integer implementation for 8-bit microcontroller

I'm working on OKI 431 microcontroller. This is 8-bit microcontroller. We don't like to have any floating point operation to be performed in our project so we've eliminated all floating point operations and converted them into integer operations in some way. But we cannot eliminate one floating point operation because optimizing the calc...