I know this.
Calling C function from C++:
If my application was in C++ and I had to call functions from a library written in C. Then I would have used
//main.cpp
extern "C" void C_library_function(int x, int y);//prototype
C_library_function(2,4);// directly using it.
This wouldn't mangle the name C_library_function and linker wou...
I am using DJGPP compiler for DOS in that i have to use WINDOWS.h which is a win32 api for conversion of system time to file time for NTFS file system.As windows.h is win32 api it is giving error "windows.h-no such file or directory".So how to convert system time to file time (i.e.8 byte structure) in NTFS file system for NTFS file syste...
I need little help on following requirement, as I know very little about C syntax.
I have data in a file like this
73 54 57 [52]
75 73 65 [23]
65 54 57 [22]
22 59 71 [12]
22 28 54 [2]
65 22 54 73 [12]
65 28 54 73 [52]
22 28 65 73 [42]
65 54 57 73 [22]
22 28 54 73 [4]
Where values in bracket denotes the occurrence of that series. I ne...
Hello,
I have a thread function on Process B that contains a switch to perform certain operations based on the results of an event sent from Process A, these are stored as two elements in an array.
I set the first element to the event which signals when Process A has data to send and I have the second element set to the event which ind...
I am working on the firmware for a device that uses an 8bit mcu (8051 architecture). I am using SDCC (Small Device C Compiler). I have a function that I use to set the speed of a stepper motor that my circuit is driving. The speed is set by loading a desired value into the reload register for a timer. I have a variable, MotorSpeed that ...
how to enable external interrupt of 8051?
...
Hi...i have a text file where the first number defines the size of the arrays. I know that calloc or malloc can reserve memory, but how?
this code:
typedef struct alpha {
int* size;
char name;
int tot;
char line[60];
} ALPHA;
fgets(line, 60, fp);
tot = atoi(line);
size = (int*)calloc(name, sizeof(int);
Imagine that ...
Given integer values x and y, C and C++ both return as the quotient q = x/y the floor of the floating point equivalent. I'm interestd in a method of returning the ceiling instead. For example, ceil(10/5) = 2 and ceil(11/5) = 3.
The obvious approach involves something like:
q = x / y;
if (q * y < x) ++q;
This requires an extra compar...
Is there any unit testing framework for C like JUnit and Nunit for java and .NET?
Or how do we test a piece of code written in C for different scenarios?
Thanks in advance......
...
Similar to the C++ question, what C blogs do you regularly follow? This can include FAQs, puzzles, quizzes, etc...
Please add one URL per posting
...
When working sometimes ago on an embedded system with a simple MMU, I used to program dynamically this MMU to detect memory corruptions.
For instance, at some moment at runtime, the foo variable was overwritten with some unexpected data (probably by a dangling pointer or whatever). So I added the additional debugging code :
at init, t...
In the good old days of C. I could cast a float to an int (assuming 32 bit system), do some bit manipluation ( bitwise and, right shift, ect ), and get the upper and lower 16 bit hex representations of the floating point number, which I could then store in two short values. I'm not seeing an easy way of doing this in C#.
System.Convert....
I've got a buffer overrun I absolutely can't see to figure out (in C). First of all, it only happens maybe 10% of the time or so. The data that it is pulling from the DB each time doesn't seem to be all that much different between executions... at least not different enough for me to find any discernible pattern as to when it happens. ...
I'm currently passing an array to a function, then attempting to use glGenBuffers with the array that is passed to the function. I can't figure out a way to get glGenBuffers to work with the array that I've passed. I have a decent grasp of the basics of pointers, but this is beyond me.
Buffers are generated (and deleted) elsewhere. I ca...
I have a 32 bit long variable, CurrentPosition, that I want to split up into 4, 8bit characters. How would I do that most efficiently in C? I am working with an 8bit MCU, 8051 architectecture.
unsigned long CurrentPosition = 7654321;
unsigned char CP1 = 0;
unsigned char CP2 = 0;
unsigned char CP3 = 0;
unsigned char CP4 = 0;
// What do I...
I have a function that returns a different DWORD value for each case there is an error. So I have the following defines:
#define ERR_NO_DB_CONNECTION 0x90000
#define ERR_DB_NOT_OPEN 0x90001
#define ERR_DB_LOCKED 0x90002
#define ERR_DB_CONN_LOST 0x90003
Now, I return those values when an error occurs.
I nee...
Hi can we hide variables in a structure from outside of the given file using static keyword???
similarly can we hide a global variable from outside of the given file using static keyword?
if so please let me know how.
Thanks in advance...
...
Hey Stackoverflow I'm working on my homework and I'm trying to reverse a circular-linked deque without a sentinel. Here are my data structures:
struct DLink {
TYPE value;
struct DLink * next;
struct DLink * prev;
};
struct cirListDeque {
int size;
struct DLink *back;
};
Here's my approach to reversing the deque:
void revers...
I am new at C programming. I thought when you type something like #define Const 5000 that the compiler just replaces every instance of Const with 5000 at compile time. Is that wrong?
I try doing this in my code and I get a syntax error. Why can't i do this?
#define STEPS_PER_REV 12345
... in some function
if(CurrentPosition >= STEPS_PE...
Hi,
I'm writing a bignum library, and I want to use efficient data types to represent the digits. Particularly integer for the digit, and long (if strictly double the size of the integer) for intermediate representations when adding and multiplying.
I will be using some C99 functionality, but trying to conform to ANSI C.
Currently I h...