c

Fuse Filesystem

Help me please... I don't know to do. This error: error: invalid conversion from ‘int (*)(const char*, fuse_file_info*)’ to ‘int (*)(const char*, int)’ when i do static struct fuse_operations vkfs_opers; ... vkfs_opers.open = vkfs_open; but function declarated as static int vkfs_open(const char *path, struct fuse_file_info *fi...

How does one do Raw IO on Mac OS X? (ie. equivalent to Linux's O_DIRECT flag)

Hi, I having been googling for a way to do raw (sometimes called direct) i/o under mac os. Raw i/o turns of the operating system page cache to give the application more direct access to the disk. This is useful because some of the filestructure I am using are not efficient using LRU page replacement. It is fairly straight forward to imp...

c fOpenThread() is this part of a header file, any info

Hi, Visual Studio 2008 C XP SP3 I am reading a book by Hoglund and he uses: HANDLE hThread = fOpenThread( THREAD_ALL_ACCESS, FALSE, dbg_evt.dwThreadId); Anybody know anything about fOpenThread as I can't find any details and I am getting the error message error C3861: 'fOpenThread': iden...

Problem with sprintf function, last parameters are wrong when written

So I use sprintf sprintf(buffer, "%f|%f|%f|%f|%f|%f|%d|%f|%d", x, y, z, u, v, w, nID, dDistance, nConfig); But when I print the buffer I get the 2 last parameters wrong, they are lets suppose to be 35.0000 and 0 and in the string they are 0.00000 and 10332430 and my buffer is long enough and all the other parameters are good in the st...

How to flush Input Buffer of an UDP Socket in C ?

How to flush Input Buffer (if such thing exists at all) of an UDP Socket in C ? I'm working on an embedded Linux environment and using C to create some native application. There are several of these embedded machines on the same network, and when an event occurs on one of them (lets call it the WHISTLE-BLOWER), WHISTLE-BLOWER should sen...

Using C++ to import registry files

Hello everyone, I'm having some problems of getting the following simple code to run correctly: #include <process.h> int main( void ) { system("foo.reg"); //why does this NOT WORK?! //system("reg import foo.reg"); //why does this NOT WORK?! //system("regedit \"foo.reg\""); //why does this NOT WORK?! return 0; } ...

How do you fill an array with strings in C?

I'm trying to fill an array with names from a file: Andrew Andy Bob Dan Derek Joe Pete Richy Steve Tyler Here is the function I wrote...but the program crashes when I run it: #include <stdio.h> main(){ int i=0, size=10; char fname[15]; char** data; char* name; FILE* fp; printf("Enter a filename to read names:\n"); sca...

C newbie can't find Syntax Error

I'm having trouble finding the error in the following code: #include <stdio.h> #define LOOP 0 #define ENDLOOP 1 main() { int c, loop; loop = LOOP; while ((c = getchar()) loop != ENDLOOP) { if (c == 'e'|| c == 'E') { printf ("END LOOP\n"); loop = ENDLOOP; } else if (c == 'c' || c == 'C') ...

Difference between pointers to variables, and pointers to structures in C

In learning C, I've just begun studying pointers to structures and have some questions. Suppose I were to create a structure named myStructure, and then create a pointer myStructurePointer, pointing to myStructure. Is *myStructurePointer, and myStructure two ways of referencing the same thing? If so, why is it necessary to have the ...

Using argv in C?

For an assignment, I am required to have command line arguments for my C program. I've used argc/argv before (in C++) without trouble, but I'm unsure if C style strings are affecting how this works. Here is the start of my main: int main(int argc, char *argv[]){ if(argc>1){ printf("0 is %s, 1 is %s\n",argv[0],argv[1]); if(a...

How can I avoid "duplicate symbol" errors in xcode with shared static libraries?

I have static libraries A, B and C organized into Xcode projects. A and B depend on C. When I build an iPhone project that depends on A and B, I get a linker error that a duplicate symbol (from C) was detected in A and B. How can I organize these three static libraries so I can include them in other Xcode projects without experiencing...

Determine word size of my processor

How do I determine the word size of my CPU? If I understand correct an int should be one word right? I'm not sure if I am correct. So should just printing sizeof(int) would be enough to determine the word size of my processor? ...

Saving PNG images

I'm having trouble saving png images. I want to add some binary data into the png file, such as the following structure. struct Foo { int value; char str[10]; double val; double val2; }; It seems to save just fine with the following code. However, when I later load up the png file, I see that my chunk has not be...

Calculate all modes in c

Can you give me some hint on how to calculate if there are two or more modes in c? I was able to create a program that will calculate for the mode, but if i have a dataset with multiple modes, like 5,3,1,2,3,4,6,4 my program only finds 3 as a mode, rather than both 3 and 4. ...

Undefined/Unspecified/Implementation-defined behaviour warnings?

Can't a compiler warn (even better if it throws errors) when it notices a statement with undefined/unspecified/implementation-defined behaviour? Probably to flag a statement as error, the standard should say so, but it can warn the coder at least. Is there any technical difficulties in implementing such an option? Or is it merely imposs...

What defines an opaque type in C, and when are they necessary and/or useful ?

I've seen the concept of 'opaque types' thrown around a bit but I really haven't found a succinct answer as to what defines an opaque type in C and more importantly what problems they allow us to solve with their existence. Thanks ...

What does the code "DECLDIR __declspec(dllexport)" really do?

#ifndef _DLL_TUTORIAL_H_ #define _DLL_TUTORIAL_H_ #include <iostream> #if defined DLL_EXPORT #define DECLDIR __declspec(dllexport) #else #define DECLDIR __declspec(dllimport) #endif extern "C" { DECLDIR int Add( int a, int b ); DECLDIR void Function( void ); } #endif What does the code DECLDIR __declspec(dllexport) really do? ...

mmap-loadable data structure library for C++ (or C)

I have a some large data structure (N > 10,000) that usually only needs to be created once (at runtime), and can be reused many times afterwards, but it needs to be loaded very quickly. (It is used for user input processing on iPhoneOS.) mmap-ing a file seems to be the best choice. Are there any data structure libraries for C++ (or C)?...

need help with conditional gdb debugging (of C code)

I have a C code similar to: int f() { for (int i = 0; i < 100; i++) { scanf flag; if(flag) scanf data1; scanf data2; } } I want to break the execution only when flag == 0. How should I set the breakpoint (using gdb)? ...

Using libmms from Objective-C

Hi, I want to use libmms in an objective-c project. I've taken the project from here - http://www.tunein-radio.com/lgpl.html - and included the libmms library in my own project. This avoids me having to compile libmms myself. Initially I just want to see if it works and hopefully output some audio. Here's what I have so far in my heade...