Hi All,
I am trying to figure out how many clock cycles or total instructions it takes to access a pointer in C. I dont think I know how to figure out for example, p->x = d->a + f->b
i would assume two loads per pointer, just guessing that there would be a load for the pointer, and a load for the value. So in this operations, the point...
HI...i want to write something like this in a file, using fwrite
fwrite("name is %s\n",name, 60, fp);
but is not working, only write in the file the string. any idea?
...
I have a loop here and I want to make it run faster. I am passing in a large array. I recently heard of Duff's Device can it be applied to this for loop? any ideas?
for (i = 0; i < dim; i++) {
for (j = 0; j < dim; j++) {
dst[RIDX(dim-1-j, i, dim)] = src[RIDX(i, j, dim)];
}
}
...
I'm a bit new to malloc and C in general. I wanted to know how I can, if needed, extend the size of an otherwise fixed-size array with malloc.
Example:
#define SIZE 1000
struct mystruct
{
int a;
int b;
char c;
};
mystruct myarray[ SIZE ];
int myarrayMaxSize = SIZE;
....
if ( i > myarrayMaxSize )
{
// malloc another SIZE (1000)...
How do I get a variable's type in c? Objective c has className, php has get_class(), etc...
...
Hi everyone,
I have a simple test application (in C) that grabs mmaped frames from my v4l device. And now, I'd like to display these frames within a tiny LessTif application (like gnome cheese, but only displaying the frames - nothing else). Do you have an idea how to implement such a LessTif program?
Thanks,
Dan
...
Hi,
I wanted a non recursive approach to the problem of generating combination of certain set of characters or numbers.
So, given a subset k of numbers n, generate all the possible combination n!/k!(n-k)!
The recursive method would give a combination, given the previous one combination.
A non recursive method would generate a combin...
hello.
Is there a way to define using typedef integral/float type which implies no aliasng?
something equivalent to (but primitive construct):
template < typename T >
struct restrict { T* __restrict data; };
as related question, is it possible to ask gcc what it determines alias/no alias of pointer is?
...
I have C# background. Very newbie to low level language like C.
In C#, struct's memory laid out by compiler by default. Compiler can re-order data fields or pads additional bits between fields implicitly. So I had to specify some special attribute to override this behavior for exact layout.
As I know, C does not re-order or align memor...
They are located under:
share\gtk-2.0\demo
But none of them contains a main function, how can I make the following textscroll.c actually work:
/* Text Widget/Automatic scrolling
*
* This example demonstrates how to use the gravity of
* GtkTextMarks to keep a text view scrolled to the bottom
* while appending text.
*/
#include ...
I study this code from some book:
#include <pthread.h>
#include <stdio.h>
/* Parameters to print_function. */
struct char_print_parms {
/* The character to print. */
char character;
/* The number of times to print it. */
int count;
};
/* Prints a number of characters to stderr, as given by PARAMETERS,
which is a...
I am confused by the specification of mmap.
Let pa be the return address of mmap (the same as the specification)
pa = mmap(addr, len, prot, flags, fildes, off);
In my opinion after the function call succeed the following range is valid
[ pa, pa+len )
My question is whether the range of the following is still valid?
[ rou...
I can initialize float32x4_t like this:
const float32x4x4_t zero = { 0.0f, 0.0f, 0.0f, 0.0f };
But this code makes an error Incompatible types in initializer:
const float32x4x4_t one =
{
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
};
float32x4x4_t is 4x4 matrix bui...
It seems to me that both functions can be used to add some widget to the container.
What's the difference?
...
In a C function declaration, I have seen this parameter definition:
void *userData
so, what exactly is that? My guess: the void says it can be anything arbitrary, or even nothing. Almost similar to id of objective-c. It just allows to pass in whatever data structure you like.
The star in front of userData says, that the argument must...
There's an AudioFileOpenURL function which opens an file. With AudioFileReadPackets that file is accessed to read packets. But one thing that stucks in my brain is: Does AudioFileOpenURL actually load the whole monster into memory? Or is that a lightweight operation?
So is it possible to read data from a file, only a specific portion, w...
I try to grok that: Apple is talking about "packets" in audio files, and there is a fancy function called AudioFileReadPackets which takes a lot of arguments. One of them specifies the "start packet", and another one the number of packets which you want to read.
So I imagine an audio file to look like this, internally: It's made up of a...
I'm making a vector/matrix library. (GCC, ARM NEON, iPhone)
typedef struct{ float v[4]; } Vector;
typedef struct{ Vector v[4]; } Matrix;
I passed struct data as pointer to avoid performance degrade from data copying when calling function. So I designed function like this at first:
void makeTranslation(const Vector* factor, Matrix* re...
Hi,
I have Ubuntu 8.04 running on a Xen based VPS server that runs on a dual-core AMD Opteron 64-bit machine.
I have some locally developed C++ based daemons that I would want to deploy in that machine. My local machine is a 32 bit Ubuntu 9.04 running on an Intel core 2 duo laptop.
Can I execute binaries compiled from source code ...
Hi,
I`am experimenting with shellcode and stumbled upon the nop-slide technique. I wrote a little tool that takes buffer-size as a parameter and constructs a buffer like this: [ NOP | SC | RET ], with NOP taking half of the buffer, followed by the shellcode and the rest filled with the (guessed) return address. Its very similar to the t...