There is a set of N real-time data-independent tasks. Each of the tasks processes some digital data stream. A data stream for each task comes from an input port and a resulted stream then is being directed to an output port.
1) What is computationally less intensive: tasks in form of the processes or threads?
2) Does best choice depen...
i have a c-application which should load a shared object at runtime and call an arbitrary function of the shared object. The shared object was build by the user and gave me the signature of his function.
int func(int a, int b, double c)
i use dlopen to load the object and dlsym to get a function pointer to the shared object function...
Suppose user enter a integer "3", the matrix should 3 X 3 and some random numbers in it.
For example:
8 0 2
6 3 4
5 7 1
I need to use 2D array to do it.
But I have no idea about how to finish it. Here is my code, what should I do now?
#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
int _tmain(int argc, _TCHAR* argv[])...
Any idea what this means? Not sure of the language.
(void *) 0x00
...
I think I have an advanced knowledge of C++, and I'd like to learn C.
There are a lot of resources to help people going from C to C++, but I've not found anything useful to do the opposite of that.
Specifically:
Are there widely used general purpose libraries every C programmer should know about (like boost for C++) ?
What are the m...
I'm doing post graduation in computer science. In the second semester I wish to do a game in C or C++ so that I can apply my knowledge in these languages and this will add to my existing knowledge about these languages. Please suggest to me a good topic and a brief description about it. I have one of my classmates with me to do the proje...
I'm currently exploring interfacing C and R (using R's .Call for speed). I've only used C for trivial integer computation and text processing applications, and I've never had to worry about issues with float variables, underflow, etc. What tests can I write for functions to ensure numerical accuracy?
...
I just saw this block of code on the Wikipedia article on conditional operators:
Vehicle new_vehicle = arg == 'B' ? bus :
arg == 'A' ? airplane :
arg == 'T' ? train :
arg == 'C' ? car :
arg == 'H' ? horse :
feet;...
I am writing code that compares 2 bytes which represent integers. I want to see if byte R is with +-10 of G. The problem I am having with the code is with the comparison in the if-statment near the end. The bytes never come out as being out of range, even when they should. I am sure the problem comes from how I am adding/subtracting the ...
I've spent my professional life as a C# developer. As a student I occasionally used C but did not deeply study it's compilation model. Recently I jumped on the bandwagon and have begun studying Objective-C. My first steps have only made me aware of holes in my pre-existing knowledge.
From my research, C/C++/ObjC compilation requires all...
I just wrote the following line of code:
if (++(data_ptr->count) > threshold) { /*...*/ } // example 1
My intent is to increment the count variable within the data structure that data_ptr points to before making the comparison to threshold, and this line of code works.
If I had instead wanted to increment data_ptr before making the c...
What i need is a function that modifies given pointer to 2d matrix like this:
void intMatrixAll(int row, int col, int **matrix);
Now, a function should allocate memory and the matrix could be used. Rows and cols are given at run-time.
#include <stdio.h>
#include <stdlib.h>
#define PRINTINT(X) printf("%d\n", X);
void intMatrixAll(in...
I need to prevent application's memory pages from being swapped out of RAM on Windows. Is there a WinAPI function equivalent of POSIX mlockall() to achieve that?
...
I need a function that, given a character, returns the CGKeyCode associated with the position of that character on the current keyboard layout. E.g., given "b", it should return kVK_ANSI_B if using U.S. QWERTY, or 45 if using Dvorak. The Win32 API has the function VkKeyScan() for this purpose; X11 has the function XStringToKeySym(). Is t...
Just curious if u_char is a standard. I've always used it assuming it was defined along with uintX_t types and so on. But am seeing some of our code base transition from u_char to "unsigned char" with a reason "so users don't have to define u_char themselves"..
...
How do you allocate memory that's aligned to a specific boundary in C (e.g., cache line boundary)? I'm looking for malloc/free like implementation that ideally would be as portable as possible --- at least between 32 and 64 bit architectures.
Edit to add: In other words, I'm looking for something that would behave like (the now obsolet...
I am trying to create a symbol table using an array of an array of structs.
Right now I just have an array of structs and it's created like this:
#define MAXSIZE 20 /* maximum number of symbols */
#define MAXSCOPE 10 /* maximum number of scope levels */
struct tableEntry {
char *name;
char *args;
int value;
int scope;
char *type...
I could compile the void main() as c++ source file with microsoft c/c++ compiler 14.00 (integrated with visual studio 2005).So does it means that the compiler does not conform to the c++ standard on the main function prototype?
Is the microsoft c/c++ compiler only one compiler,that is,it is only one c++ compiler?Because C source file co...
Const-correctness in C++ is still giving me headaches. In working with some old C code, I find myself needing to assign turn a C++ string object into a C string and assign it to a variable. However, the variable is a char * and c_str() returns a const char []. Is there a good way to get around this without having to roll my own function ...
I'm trying to use pass by reference in C so that the function can modify the values of the parameters passed to it. This is the function signature:
int locate(char *name, int &s, int &i)
However when I try to compile it I get this error that refers specifically to the above line:
error: expected ‘;’, ‘,’ or ‘)’ before
'&' token...