Is there a way to do a quick and dirty 3D distance check where the results are rough, but it is very very fast? I need to do depth sorting and im using stl sort like this:
bool sortfunc(CBox* a, CBox* b)
{
return a->Get3dDistance(Player.center,a->center) <
b->Get3dDistance(Player.center,b->center);
}
flo...
I am trying to build the OSKit source code. It is orginally written against gcc 2.95.2, but on my box I got gcc 4.3.2. And 4.3.2 doesn't allow the following syntax:
asm volatile("
pushfl
popl %0" : "=r" (eflags));
return eflags;
4.3.2 always complains that:
error: missing terminating " character
There're so many syntax like t...
The question is how to get the length of dynamically allocated 2D Arrays in C? I thought the code below should get the number of rows, but it doesn't.
char** lines;
/* memory allocation and data manipulation */
int length; //the number of rows
length = sizeof(lines)/sizeof(char*);
Any thoughts on this?
...
I hope this has a technical (rather than a religious) answer, but I wonder if I should use Objective-C or C++ to create an OpenGL ES Application on the iPad?
As the ultimate goal would be to compile it on Windows and OS X as well, I'm inclined to use C++ (and only use ObjC for the stuff that I have to: App Delegate etc.), but I have zer...
hi, i have written a C programme which prints itself n times, but i can't get how to reverse print the same n times.E.g, if the sample programme is :
hello
then the required output should be "olleh" for n=1.
Here's my quine programme,
#include <stdio.h>
int main()
{
int n;
char c;
FILE *f;
f=fopen(__FILE__,"r");
scanf("%d"...
Hi, all!
Q1.I want to match "&JOY" in a user input string, for example, "bla bla &JOY bla bla &JOY blabla"
How can I write the regex expression for this, and are there any C regex functions could return all the positions where the matches happen?
Q2.If I want to substitute &JOY with another string is there a convenient C function to do t...
I'm looking for the fastest way to popcount on large buffer of 512 or more bytes. I can guarantee any required alignment, and the buffer size is always a power of 2. The buffer corresponds to block allocations, so typically the bits are either all set, none set, or mostly set favoring the "left" of the buffer, with occasional holes.
Som...
Using a microcontroller (PIC18F4580), I need to collect data and send it to an SD card for later analysis. The data it collects will have values between 0 and 1023, or 0x0 and 0x3FF.
So what I need to do is convert 1023 into a base 10 string of literal ASCII values (0x31, 0x30, 0x32, 0x33, ...).
My problem is that the only way I can th...
The stdint.h header lacks an int_fastest_t and uint_fastest_t to correspond with the {,u}int_fastX_t types. For instances where the width of the integer type does not matter, how does one pick the integer type that allows processing the greatest quantity of bits with the least penalty to performance? For example, if one was searching for...
Hello all, I'm trying to use tpl to serialize structs that contain wchar_t* strings.
The code I have looks like this, and it's not working:
#include <stdio.h>
#include <locale.h>
#include <string.h>
#include <wchar.h>
#include "tpl.h"
struct chinese_t {
wchar_t *chars;
};
int main() {
tpl_node *tn;
struct chinese_t cstr;
cstr...
I was wondering what I needed to know in terms of C to move onto Objective-C. I would be uber-grateful if you could let me know what you think is sufficient to move on Objective-C.
Thanks,
~Daniel
...
I'm working on a homework assignment for CS1, and I almost have it finished but errors keep popping up in relation to a few functions I've tried to implement. The assignment is the classic addition and subtraction of big integers using linked lists. My issue isn't with any of mathematical functionality of the program, but rather getting ...
I would like to start coding a gtk theme engine, but i'm wondering where i can find some documentation, if any exists.
I know how to have look at someone else engine's code, examples, or torture tests and widget factories etc.., what i want instead is any documentation type, design, references, examples or tutorials possibly from reliabl...
Given:
char test[]="bla-bla-bla";
Which is more correct:
(1)
char *test1 = malloc(strlen(test));
strcpy(test1,test);
or (2)
char *test1 = malloc(sizeof(test));
strcpy(test1,test);
...
Hello. I'm struggling to find why I can't free a memory block. Something must be wrong with the pointer. A memory block for a structure is made in a function and the pointer used is stored in an array. Later the pointer is taken from the array to be used to free the memory.
I've figured out which free it is. I've placed "//This one" nex...
it's function for generate md5hash:
out = malloc(32+1);
void md5sum( u_char *secret_data, int secret_len, char *in,char *out ) {
ngx_md5_t md5;
u_char hash[16];
ngx_md5_init(
ngx_md5_update(
ngx_md5_update(
ngx_md5_final(hash,
int ii;
for (ii = 0; ii 16; ii++) {
...
NULL in C programming can anyone tell me how NULL is handled in C ?
and output of program is 3 how with NULL concept ?
#include "stdio.h"
void main() {
int i;
static int count;
for(i=NULL;i<=5;) {
count++;
i+=2;
}
printf("%d",count);
}
...
Hello,
I am working on a project in C which requires me to read in matrix values from a txt file. The first two lines are the number of rows and columns, and the rest is the actual matrix data.
For example, something like this:
2
2
1.0 2.0
3.0 4.0
The code I wrote is giving me some issues. Here's a snippet:
matrix read(char* file...
Is there a way to convert a Delphi .dcu file to an .obj file so that it can be linked using a compiler like GCC? I've not used Delphi for a couple of years but would like to use if for a project again if this is possible.
...
Suppose you have the following C code
unsigned char a = 1;
printf("%d\n", ~a); // prints -2
printf("%d\n", a); // prints 1
I am surprised to see -2 printed as a result of ~1 conversion:
Opposite of 0000 0001
is 1111 1110 --> anything but -2
What am i missing here? please advise
...