c

How can I call a C++ function from C?

I have a header declaring functions that take pointers to C++ objects as parameters. The implementaton is in a seperate C++ file. How can I include this header in C and use the functions in C even though the arguments need to be C++ object pointers? ...

What does an 'F' in the Format specifier of printf mean ?

What does %.8Ff format specifier in printf do?What does F mean? ...

how to load files from any directory in c programme

i want to change this code below for the inwashfile to be able to load from any directory instead of loading from the tech_projects environmental variable. /**Get projects directory from environment variable****************/ strcpy(pjects.arr, getenv("Tech_Projects")); pjects.arr[strlen(pjects.arr)] = '\0'; if (strcmp(inwashfil...

C arrays in objective C

I'm new to obj-c and I'm used to creating a property declaration for all my member vars and synthesizing them, just got the hang of it in fact. Along comes a need for a simple C array of a struct I typedeffed myself (I guess the struct aspect doesn't really matter). Can someone explain what I should be doing with this C array as far as...

SIMD code for exponentiation

Hi all, I am using SIMD to compute fast exponentiation result. I compare the timing with non-simd code. The exponentiation is implemented using square and multiply algorithm. Ordinary(non-simd) version of code: b = 1; for (i=WPE-1; i>=0; --i){ ew = e[i]; for(j=0; j<BPW; ++j){ b = (b * b) % p; if (ew...

Variable declaration and definition

int x; Is this declaration or definition ? As I write the following code, #include <stdio.h> int main(void) { int x; printf("%p",&x); return 0; } it prints some address.So as memory is allocated , int x; can't be a declaration. So is it a definition ? ...

Find ALL paths in a grid between 2 nodes

I'm trying to find all the paths between 2 nodes in a grid, and the path has to go through all the node from start to end. Example (Start = S, End = E) 0 0 0 0 S 0 0 0 E The answer for the above is 2 paths: (ignore the '.''s) 0-0-0 |.......| 0 S-0 | 0-0-E 0-0-0 |......| 0 S 0 |...|...| 0-0 E I thought of using recursing, but g...

how to cast from one type to another in c

I have following code #include <stdio.h> #include<ctype.h> typedef struct { int Type; int Type2; }foo; typedef struct { char cData[40]; }bar; int main() { bar b1; strcpy(b1.cData,"11"); foo *f=(struct foo *)&b1; printf("Type is %d \n",f->Type); return 0; } But i am not getting the value of type 1 in f's pointer , i...

Libjpeg error - improper call in state 205

Hi everyone, I'm using libjpeg (C/C++ programming on Windows Mobile 6.5), in order to decode images from an IP camera (sent in a MJPEG stream), before pushing them into a DirectShow graph. Until now, I've been using a single function for : receiving the stream, parsing it manually (in order to find JPEG data starting- and end-point), d...

Perhaps a pointer problem. Linux program + libpcap + getopt_long() + C language.

Hello! I'm making a network sniffer for my college project using the libpcap library. Majority of the code works without any problem, however, I'm stuck with the following issue. I've added five command line options using getopt_long() function, but one option doesn't work as expected. The option is -d (--device_info) and is used to pri...

Compiling C code, does not see a #define'd constant

Greetings. I am trying to compile a 8hz mp3 encoder - C code in QT Creator. In a file l3psy.c that starts like this #include <stdio.h> #include "types.h" #include "error.h" #include "layer3.h" #include "l3psy.h" #include "fft.h" #include "tables.h" The build step complains about PI being undeclared here for(i=0;i<BLKSIZE;i++) wi...

How do I write a compiler in C?

Hi. This amu. I want to write a compiler in C. Whats basics do I have to learn for creating a compiler? ...

Auto correction , auto complete features

Hii , We see suggestions when we type a word in Ms-word , google etc... How do they do that ? I would like to know how the techniqueslike auto correct , auto complete , spell checking etc.. are performed . HOw are the words actually stored... what algorithms are followed ... ??? Any links that suggest a possible way are welcome, ...

best way to switch on a string in C

I just wonder how can I switch on the string "B1" ? Don't ask why this string :-) ...

C/C++ Serialize Fast : Boost vs Cpickle vs Json vs Protocol buffer

Hi, I need to serialize C/C++ structure in a binary string,very fast. Env = Windows,Boost 1.44,Python 2.4. We have 3 structures differents to serialize: Basic : int,double,long,float,string (or char*) Vector: - Each element can be : Basic or Vector or a Map --> vector< Basic,Vector,Map > Map: - Each Value element c...

How to call a lib written in C++ from C ?

It seems to me like a no-brainer, but I cannot find any information against or for it. From the point of view of demangling etc, I don't suppose this to be a big problem, but I can't figure out, how I can write a little tiny C program which calls a function from a little tiny C++ library. I am on linux right now, trying with static bin...

looking for tool that format and escape long text string to valid c char*

Hello all i looking for a tool that takes long text string to valid const char *fmt for example i want to set char* with this java script as string: http://code.google.com/p/swfobject/link text in simple words i need to properly escape the java script string so i could printf() it later i hope now its clear Thanks ...

qsort not sorting structure correctly.

Hi, I'm trying to sort a structure I've created via qSort however it seems to be be doing what I expect it to. This is my compare function int compare(const void *a, const void *b) { const INPUT *p1 = a; const INPUT *p2 = b; return ((p1->startTime) - (p2->startTime)); } Where INPUT is my structure and startTime is an int...

What data structure to use?

Hello, I need a data structure with the following properties: Access to elements must be very fast Elements, that are not added, shouldn't take memory (as ideal, size of empty structure near to zero) Each element has two integer coordinates (x,y) (access to elements only by them) Max count of elements known at creation time (over 10^3)...

SIMD version check

Hi, I am using Intel Core2Duo E4500 processor. It is supposed to have SSE3, SSSE3 facilities. But if I try to use them in programs it shows the following error "SSE3 instruction set not enabled" Any ideas? ...