c

using C function in C#

i have a dll, built with mingw one of the header files contains this: extern "C" { int get_mac_address(char * mac); //the function returns a mac address in the char * mac } I use this dll in another c++ app, built using Visual C++ (2008SP1), not managed, but plain c++ (simply include the header, and call the function) But now I ha...

SO_LINGER and closing sockets(WINSOCK)

hey. im writing a multithreaded winsock application and im having some issues with closing the sockets. first of all, is there a limit for a number of simultaneously open sockets? lets say like 32 sockets all in once. i establish a connection on one of the sockets, and passing information and it all goes right. problem is when i disconn...

Can I use relative XPath expressions in libxml2?

I am wondering whether it is possible to use relative XPath expressions in libxml2. This is from the javax.xml.xpath API and I would like to do the similar thing using libxml2: Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE); With a reference to the element, a relative XPath expression can n...

How to pass a multidimensional array to a function in C and C++

#include<stdio.h> void print(int *arr[], int s1, int s2) { int i, j; for(i = 0; i<s1; i++) for(j = 0; j<s2; j++) printf("%d, ", *((arr+i)+j)); } int main() { int a[4][4] = {{0}}; print(a,4,4); } This works in C, but not in C++. error: cannot convert `int (*)[4]' to `int**' for argument `1' to `vo...

SOCKS in C/C++ or another language?

How do i add SOCKS support to my application? and where can i get the libs? any help appreciated thanks ...

error C2109: subscript requires array or pointer type

I am trying to debug some homework but I am having trouble with these lines of code #include "stdafx.h" #include<conio.h> #include<iostream> #include<string> using namespace std; int main() { char word; cout << "Enter a word and I will tell you whether it is" << endl << "in the first or last half of the alphabet." << endl << ...

Why does this program segfault

Upon compiling and running this small program to reverse a string, I get a Segmentation Fault before any output occurs. Forgive me if this is an obvious question, I'm still very new to C. #include <stdio.h> int reverse(char string[], int length); int main() { char string[] = "reversed"; printf("String at start of main = %s", stri...

Choosing sound codec for network (c/c++)

Hi, I'am imnplementing real-time sound (voice) recording and transferring to another point in my application. I would ask who knows good codec or compression algorithm to transfer low-quality (max 32 kbit) sound data through the network. I know skype uses good compression, what codec use it? *It should be free I found also this code...

Cant access NString after callback in [NSURLConnection sendSynchronousRequest]

Hi I am trying to get a cookie from a site which I can do no problem. The problem arises when I try and save the cookie to a NSString in a holder class or anywhere else for that matter and try and access it outside the delegate method where it is first created. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRe...

C functions invoked as threads - Linux userland program

I'm writing a linux daemon in C which gets values from an ADC by SPI interface (ioctl). The SPI (spidev - userland) seems to be a bit unstable and freezes the daemon at random times. I need to have some better control of the calls to the functions getting the values, and I was thinking of making it as a thread which I could wait for to ...

is there any tools that can extract all variables(both public and static) from a set of C files?

Hi Guys, I'm wondering if there is any tools that can extract all variables(both public and static) from a set of C files and then export all referenced variables to a text file. Thanks in advance. ...

Only compiles as an array of pointers, not array of arrays

Suppose I define two arrays, each of which have 2 elements (for theoretical purposes): char const *arr1[] = { "i", "j" }; char const *arr2[] = { "m", "n" }; Is there a way to define a multidimensional array that contains these two arrays as elements? I was thinking of something like the following, but my compiler displays warnings ab...

How can I create C header files.

I want to be able to create a collection of functions in a header file that I could #include in one of my C Programs. ...

DialogBox in Win32 - Prevent multiple instance

Hello all, I have a program which creates DialogBox window when user clicks the menu item from tray icon, case ID_OPTIONS: DialogBox ( GetModuleHandle ( NULL ), MAKEINTRESOURCE ( IDD_SETUP_DIALOG ), hWnd, reinterpret_cast<DLGPROC>(SetupDlgProc) ); return 0;...

C preprocessor: using #if inside #define?

I want to write a macro that spits out code based on the boolean value of its parameter. So say DEF_CONST(true) should be expanded into "const", and DEF_CONST(false) should be expanded into nothing. Clearly the following doesn't work because we can't use another preprocessor inside #defines: #define DEF_CONST(b_const) \ #if (b_const) \...

zlib gzgets extremely slow?

I'm doing stuff related to parsing huge globs of textfiles, and was testing what input method to use. There is not much of a difference using c++ std::ifstreams vs c FILE, According to the documentation of zlib, it supports uncompressed files, and will read the file without decompression. I'm seeing a difference from 12 seconds using ...

Objective-C / C giving enums default values

I read somewhere about giving enums default values like so: typedef enum { MarketNavigationTypeNone = 0, MarketNavigationTypeHeirachy = 1, MarketNavigationTypeMarket = 2 } MarketNavigationLevelType; .. but i can't remember the value of doing this. If i don't give them default values - and then someone later on reorders the enum - wha...

how to write an address (pointer) in a text file that can be read and dereferenced in C

I would like to write an address in a text file, which can be read by fscanf and dereferenced by C after reading the pointer. How do I write the address in the file? edit: i don't mean to be rude, but i know that this is exactly what i need, so if anyone can please just list the answer, and not ethical reasons for why i shouldn't be doi...

What C/C++ library do I use to change an HTTP packet in windows?

It seems winpcap can't be used to do this kind of job(ref), then which library to use alternatively? ...

Does C99 guarantee that arrays are contiguous ?

Following an hot comment thread in another question, I came to debate of what is and what is not defined in C99 standard about C arrays. Basically when I define a 2D array like int a[5][5], does the standard C99 garantee or not that it will be a contiguous block of ints, can I cast it to (int *)a and be sure I will have a valid 1D array...