We are programming a ST269 microcontroller which has two IR distance sensors. To calibrate these sensors we made one table for each sensor with the distance we measured and the corresponding value we get from the ADC.
Now we want to use one function to approximate the values in between. So we defined two two-dimensional arrays (one for ...
Today I read about MD5 hash and was wondering if this is possible.
seems like a recursive problem...
or is there a solution?
...
I'm trying to implement a circular buffer in C, and have come across this example on Wikipedia. It looks as if it would provide a really nice interface for anyone reading from the buffer, as reads which wrap around from the end to the beginning of the buffer are handled automatically. So all reads are contiguous.
However, I'm a bit unsu...
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
//This program is a sorting application that reads a sequence of numbers from a file and prints them on the screen . The reading from the file here , is a call back function .
typedef int (*CompFunc)(const char* , const char* );
typedef int (*ReadCheck)(char nullcheck);
int array[...
Hi All,
I am using the following code to compute execution time in milli-secs.
struct timespec tp;
if (clock_gettime (CLOCK_REALTIME, &tp) == 0)
return ((tp.tv_sec * 1000000000) + tp.tv_nsec);
else
return ;
Can you please tell me whether this is correct?
Let's name this function comptime_nano().
Now, I write the following cod...
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
//This program is a sorting application that reads a sequence of numbers
//from a file and prints them on the screen . The reading from the file here,
//is a call back function .
typedef int (*CompFunc)(const char* , const char* );
typedef int (*ReadCheck)(char nullcheck);
char ar...
The way being suppose the data is
123 134 2312 32131 2131231 211212
It should take them as different numbers and store them in an integer array .
...
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
//This program is a sorting application that reads a sequence of numbers from a file and prints them on the screen . The reading from the file here , is a call back function .
typedef int (*CompFunc)(const char* , const char* );
typedef int (*ReadCheck)(char nullcheck);
char array...
I always seem to encounter this dilemma when writing low level code for MCU's.
I never know where to declare pin definitions so as to make the code as reusable as possible.
In this case Im writing a driver to interface an 8051 to a MCP4922 12bit serial DAC.
Im unsure how/where I should declare the pin definitions for The CS(chip sel...
C language allows jumping inside loop. What would be the use of doing so?
if(n > 3) {
i = 2;
goto inner;
}
/* a lot of code */
for(i = 0; i < limit ;i ++) {
inner:
/* ... */
}
...
I have two pointers to the same C string. If I increment the second pointer by one, and assign the value of the second pointer to that of the first, I expect the first character of the first string to be changed. For example:
#include "stdio.h"
int main() {
char* original_str = "ABC"; // Get pointer to "ABC"
char* off_by_o...
I have a program that generates packets to send to a receiver. I need an efficient method of introducing a small delay between the sending of each packet so as not to overrun the receiver. I've tried usleep() and nanosleep() but they seem to be too slow. I've implemented a busy wait loop and had more success, but it's not the most eff...
I need some help in bison grammar construction.
From my another question:
I'm trying to make a meta-language for writing markup code (such as xml and html) wich can be directly embedded into C/C++ code.
Here is a simple sample written in this language, I call it WDI (Web Development Interface):
/*
* Simple wdi/html sample source cod...
Hi, i am writing a program that takes a file and splits it up into multiple small files of a user specified size, then join the multiple small files back again.
1) the code must work for c, c++
2) i am compiling with multiple compilers.
3) I am reading and writing to the files by using the functions fread() and fwrite()
4) fread() an...
Hi here is my code. I want to dynamincly change no of elemnts in table with structs __state:
typedef struct __state{
long int timestamp;
int val;
int prev_value;
}*state_p, state_t;
int main(int argc, char **argv){
int zm;
int previous_state = 0;
int state = 0;
int i = 0;
int j;
state_p st;
//her...
The program should be able to make an array of numbers from a text file which reads like this
The data is given as this
123 2132 1100909 3213 89890
my code for it is
char a;
char d[100];
char array[100];
a=fgetc(fp) // where fp is a file pointer
if (a=='')
{
d[count1]='/0';
strcpy(&array[count],d);
count=count+1;
memset(d,'\0',100)...
I want to know how to type cast a string into integer , and not use sprintf() in C
...
I use the function "IOPMSchedulePowerEvent" to schedule Sleep or Wake-Events and registered my daemon with "IORegisterForSystemPower" to receive power-state-changes. Everything works fine!
When system going sleep and later waking up at scheduled time, my daemon do some work, and after it system should going sleep again.
Now my question...
I have some code that I am porting from an SGI system using the MIPS compiler. It has functions that are declared to have double return type. If the function can't find the right double, those functions return "NULL"
The intel C compiler does not like this, but I was trying to see if there is a compiler option to enable this "feature" s...
Any one here used C based CGI??
I have this server side code :
while (cgiFormFileRead(file, b, sizeof(b), &got_count) == cgiFormSuccess)
{
fwrite(b,sizeof(char),got_count,output);
i++;
if(i == inc && j<=100)
{
fprintf(fptr, "%d" ,j);
fseek(fptr, 0, ...