Many of today's programming languages are based on C; like C++, C#, Java, Objective-C. So could I call a C method from C++ code? Or call C from Java or C#? Or is this goal out of reach and unreasonable? Please include a quick code sample for my and everyone else's understanding.
...
Hi,
I have used timer A in MSP430 with high compiler optimization, but found that my timer code is failing when high compiler optimization used.
When none optimization is used code works fine.
This code is used to achieve 1 ms timer tick. timeOutCNT is increamented in interrupt.
Following is the code,
//Disable interrupt an...
Consider the following two struct:
struct a
{
int a;
};
struct b
{
struct a a_struct;
int b;
};
the following instantiation of struct b:
struct b b_struct;
and this condition:
if (&b_struct == (struct b*)&b_struct.a_struct)
printf("Yes\n");
Does the C standard mandate this to always evaluate true?
...
In C or C++
if ( x )
statement1;
else
statement 2;
for what value of x both statements will be executed??
I know we can execute if-else together like this:
if(1){
goto ELSE;
}
else{
ELSE:
}
Is there any way, like a value?
(Which i think is not possible. Asking because someone is arguing!)
...
i have to create a program which can have n number of nodes and each subnode can have n number of subnodes and so on, its not a binary tree.
i need to know how can one create it?
...
is there an advantage in one of the following two approaches over the other?
here it is first tested, whether fopen succeeds at all and then all the variable declarations take place, to ensure they are not carried out, since they mustn't have had to
void func(void) {
FILE *fd;
if ((fd = fopen("blafoo", "+r")) == NULL ) {
...
I'm using windows and I notice that a lot of functions are grayed out because I guess #ifdef GL_GLEXT_PROTOTYPES is not defined. One of these is the VBO extension. Should I just define GL_GLEXT_PROTOTYPES? Otherwise how else can I use VBOs since im using OpenGL32.dll (I want my application to have no dll dependencies not included in Wind...
I was wondering, since things like display lists are now deprecated, I'm thinking the GLU polygon tesselator is probably also deprecated. What is the new and correct way of creating concave or complex polygons and complying with the new GL 3 standard? Thanks.
...
I have the following program:
int insert(int *array, int arraySize, int newElement)
{
array[arraySize + 1] = newElement;
return (arraySize+1); // Return new Array size......
}
int main()
{
int array[] = {1,2,3,4,5};
int arraySize = sizeof(array) / sizeof(int);
insertInArray(array, arraySize,6);
print(array);
}
I...
So whenever I write code I always think about the performance implications. I've often wondered, what is the "cost" of using a memcopy relative to other functions in terms of performance?
For example, I may be writing a sequence of numbers to a static buffer and concentrate on a frame within the buffer, in order to keep the frame once ...
I want to calculate 2n-1 for a 64bit integer value.
What I currently do is this
for(i=0; i<n; i++) r|=1<<i;
and I wonder if there is more elegant way to do it.
The line is in an inner loop, so I need it to be fast.
I thought of
r=(1ULL<<n)-1;
but it doesn't work for n=64, because << is only defined
for values of n up to 63.
...
Hi there,
I have recently started working on my master thesis in C that I haven't used in quite a long time. Being used to Java, I'm now facing all kinds of problems all the time. I hope someone can help me with the following one, since I've been struggling with it for the past two days.
So I have a really basic model of a database: t...
I'm learning how to code in Java after after coming from C. In C I always separated everything into individual functions to make the code easier to follow and edit. I was trying to do this in java but now since I realized that you can't use pointers, I am a bit confused as to what the best way to do this is.
So for example I want to hav...
Why does Python seem slower, on average, than C/C++? I learned Python as my first programming language, but I've only just started with C and already I feel I can see a clear difference.
...
The new MacBookPros come with two graphic adapters, the Intel HD Graphics, and the NVIDIA GeForce GT 330M. OS X switches back and forth between them, depending on the workload, detection of an external monitor, or activation of Rosetta.
I want to get my feet wet with CUDA programming, and unfortunately the CUDA SDK doesn't seem to take...
Hi all, I'm currently trying to use the zlib to inflate a source of gzipped data.
It seems that the inflate API in zlib cannot inflate a gzipped data ( The example http://www.zlib.net/zpipe.c fails to read a gzipped file: "zpipe: invalid or incomplete deflate data" ). I noticed that there is a gzopen function in this API, but , as far a...
Possible Duplicate:
Where should a veteran C programmer start in order to master Java ?
Hi,
I have a lot of experience in C and Python, but I'd like to pick up some Java. I was curious if there was a "quick and dirty" guide tailored for people with previous CS background. I'd prefer free online resources but appreciate any su...
I am just curious to know what are the strategies ?
(If the strategies exists).
...
Say there is a file called 12345.jpg. In C, how can I get the file extension so that I can compare with some file extension? If there are any inbuilt functions, kindly please let me know.
...
I am developing a new project, using Autotools for my build infrastructure. I would like to subsume external dependencies into my source tree. These dependencies are using Autotools, as well. How can I configure my project's build scripts to build and link against subsumed dependencies? Though Duret-Lutz's tutorial is excellent, this sit...