c

How do I access functions from libsndfile-1.dll in MSVC?

Hi,   I'm having trouble getting libsndfile-1.dll to work in my MSVC project. I can load the library and retrieve the version string from the dll by calling sf_command() from my code. However, I can't seem to get sf__open() to return a SNDFILE pointer. I've also noticed that I can't get fopen() to return a FILE pointer either (maybe th...

Store an int in a char array?

Hey SO, This should be easy for all you C hackers out there :D Anyways, I want to store a 4-byte int in a char array... such that the first 4 locations of the char array are the 4 bytes of the int. Then, I want to pull the int back out of the array... Also, bonus points if someone can give me code for doing this in a loop... IE writi...

Boost equivalent of memcpy?

Hey all, Is there a boost equivalent for memcpy? Thanks! EDIT: Sorry, I didn't realize memcpy was in the standard library :) I thought it was an OS call :( ...

Casting a 'BigStruct' to a 'SmallStruct' in C (similar structs with static arrays of different sizes)

Supposed that for some reason you are only allowed to use static memory in a C program. I have a basic structure that I am using in several places defined as below: #define SMALL_STUFF_MAX_SIZE 64 typedef struct { /* Various fields would go here */ ... double data[SMALL_STUFF_MAX_SIZE]; /* array to hold some data */ } Small...

C++ strcmp array

Hi I am using strcmp as shown below. I am debugging the values and which are coming same but still not getting that condition true. const char opcode_read[2] = {'0', '1'}; rc = recvfrom(s, blk_receive_full, sizeof (blk_receive_full), 0,(struct sockaddr FAR *)&sin, &fromlength); if(rc == -1){ printf("failed: recvfrom, \n No data rec...

Does GCC support long long int?

Title basically says it all... does GCC support: long long int which would be a 64 bit integer? Also, is long long int part of the standard? Thanks ...

Reasons to use distutils when packaging C/Python project

I have an open source project containing both Python and C code. I'm wondering that is there any use for distutils for me, because I'm planning to do a ubuntu/debian package. The C code is not something that I could or want to use as Python extension. C and Python programs communicate with TCP/IP through localhost. So the bottom line he...

Enabling hardware watchdog in msm800

Hi I need to enable the hardware watchdog of an msm800 embedded computer. Unfortunately I hardly know anything about using assembly languages. This is what the documentation for the device says: Function: WATCHDOG Number: EBh Description: Enables strobes and disables the Watchdog. After power-up, the Watchdog is...

ANSI C functions namespace in ISO C++

Consider the following small program: #include <cstdio> int main() { printf("%d\n", 1); std::printf("%d\n", 2); return 0; } What does C++ standard say about importing C library functions into global namespace by default? Can you point me to the relevant C++ standard section? What is the reason ANSI C functions are in std...

Algorithms and Data Structures best suited for a spell checker, dictionary and a thesaurus

Best way to implement a dictionary (is their any DS better than Trie for Dictionary) thesaurus (no idea, as match is made on meanings of the words, similar meanings) spell checker (something better than a hash map), if possible with correct spelling recommendations. when asked in an 1-hr interviews, are we expected to write a...

Please help me to understand this pointer-to-pointer code.

The code is char** p = (char **) malloc(sizeof(char **) * size); //Where size is some valid value. p[1] = (char*) malloc(sizeof(char) * 30); Is the above code fine? My understanding is p -> +---------+ 0 char* + -> {c,o,d,e,\0} +---------+ +---------+ 1 char* + -> {t,o,a,d,\0} //The assignment of these value...

Unicode issue with freetype (C)

Hi guys, I currently working on a library for the NekoVM to create a binding to Freetype 2. It is written in plain c and it all works really nice, except when the user enters some unicode chars like "ü", "Ä" or "ß" they will be transformed into to some ugly square-like letters. When I recieve the data from the NekoVM you use val_string ...

Linux ioctl -> how to tell if current IP was obtained by dhcp

Hello all, I'm fiddling with the sockets ioctl's to get the current interfaces setup and I can already get the IP, interface name, netmask and check if the interface is up or down, (I just do IOCTl to SIOCGIFCONF, SIOCGIFNETMASK and SIOCGIFFLAGS). I am looking for a way to tell if my current IP address was obtained through dhcp or if ...

separating compilation for to avoid recompilation when I add some debugging to .h file

I have a .h file which is used almost throughout the source code (in my case, it is just one directory with. .cc and .h files). Basically, I keep two versions of .h file: one with some debugging info for code analysis and the regular one. The debugging version has only one extra macro and extern function declaration. I switch pretty re...

NON BLOCKING Socket

A non blocking socket is the one where we call fcntl() method and associate the O_NONBLOCK flag with it. Can any one tell me what else is required to conver a normal TCP_IP socket into a non blocking socket? What problems may arise if non-blocking sockets are made to work very well with Windows servers ? Sachin ...

How do we explain the result of the expression (++x)+(++x)+(++x)?

x = 1 i expect the answer to be 11, but it comes out to be 12. ...

Mpeg 7 Descriptors in C++

Hello, I need some descriptors of MPEG7 in C/C++. The descriptors are dominant color, color layout, color structure, scalable color, edge histogram and homogeneous texture. Do you know where can I find C/C++ source code for some of these these descriptors? Thanks ...

Stack footprint of an array of types in C

I have the following function void DoSomething(int start[10], int end[10]) When I call it via void Do(void) { int start[10] = {1,2,3,4,5,6,7,8,9,0}; int end[10] = {1,2,3,4,5,6,7,8,9,0}; DoSomething(start,end); } do I put two pointers (8 byte all together) or two arrays each of 40 bytes in size on the stack? ...

How do I calculate network utilization for both transmit and receive

How do I calculate network utilization for both transmit and receive either using C or a shell script? My system is an embedded linux. My current method is to recorded bytes received (b1), wait 1 second, then recorded again (b2). Then knowing the link speed, I calculate the percentage of the receive bandwidth used. receive utilizatio...

Set static text color Win32

I am making a dll that controls a dialogue box. I like to get a certain area to have red text. This code does compile, but the effect is not seen. Here is the area where the dialogProc is done: LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: ...