c

How to convert ruby array to C array with RubyInline?

I have a function which compares 2 strings char by char. I needed it to run much faster than it is in Ruby so I used RubyInline to rewrite the function in C. It did increase the speed about 100 fold. The function looks like this: require 'inline' inline do |builder| builder.c " static int distance(char *s, char *t){ ...

maemo scratchbox compiler error with gtk+-2.0

I'm trying to follow section 3.4.2, starting on page 31 of this manual. However, as I have configured my target to be DIABLO_ARMEL rather than DIABLO_X86, I have gotten different results for this command: [sbox-DIABLO_X86: ~] > gcc -Wall -g gtk_helloworld-1.c \ ‘pkg-config --cflags gtk+-2.0‘ -o gtk_helloworld-1 \ ‘pkg-config --libs gt...

Blanking out cstrings in a loop

I am trying to iterate through char* Is there any way to like reset these char* strings back to blank? I am trying to reset from1 and send1. Is there anything else wrong with my code.. it is only copying the first file in my array for(i = 0; i < 3; i++) { from1 = " "; send1 = " "; from1 = strncat(fileLocation,filesTo...

ld: duplicate symbol _dbg_char

Hi. Getting a linker error on osx (no errors on linux or fbsd for the same code): ld: duplicate symbol _dbg_char in .libs/liboekernel_la-OEK_get.o and .libs/liboekernel_la-OEK.o the 2 libs listed in the error are mine but the symbol isn't. c++flint confirms '_dbg_char' is in both libs but i'm not sure how to find where it comes from....

How to check if a HMENU is visible

Hi, I'm developing a Windows program in C using MFC and need to find out if a given menu (identified by a HMENU as returned by the GetMenu() function) is visible. Does anybody know how to do this? One possibility might be to test whether there is a HWND for the HMENU (a window which displays the menu). Unfortunately I couldn't find a c...

call a function named in a string variable in c

Hello everybody, I want to call a function using a variable.Is it possible in C?? Actually, what I want to do is, get the function name from the user and store it in a variable say var. Now I want to call the function that has its name stored in the variable var. Can anyone tell me how this can be done in C? Actually I want to develop ...

How to use a two-dimensional C array of Objective-C objects?

I have a two-dimensional C array of Objective-C objects. How do I access the members of those objects? id array[5][5]; array[0][0] = [[Ball alloc] init]; The Ball class has two members: int size; CGPoint point; How can I access size for the Ball object stored in array[0][0]? Please tell me how I can do this. Thanks in advance! ...

C : How to simulate an EOF ?

I am currently reading K&R's book and typing in the examples from the first section, and there are a couple of examples such as this: while((c = getchar()) != EOF) { //do something } I am testing these examples on a Windows box and thus running the compiled exe files from the cmd prompt. To test the example above, how do I simula...

How malloc() and free() work

Hi, I am curious to know about the in details about how the malloc and free works. int main() { unsigned char *p = (unsigned char*)malloc(4*sizeof(unsigned char)); memset(p,0,4); strcpy((char*)p,"abcdabcd"); // **deliberately storing 8bytes** cout << p; free(p); // Obvious Crash, but I need how it works and why cra...

Finished first year of comp sci at university... What to do for summer?

Basically we did 2 terms of Java, and one term of Unix and C in one course... I wanted to learn some stuff during summer, got some ideas for which books to read from that best books question.... But as for a language goes, what should i learn? I was thinkin of studying HTML, and CSS and JavaScript and everything else related to web des...

Where do I find the definition of size_t?

I see variables defined with this type but I don't know where it comes from, nor what is its purpose. Why not use int or unsigned int? (What about other "similar" types? Void_t, etc). ...

How do I dynamically bind a socket to only one network interface?

Currently I do the following to listen on any available port on all interfaces: // hints struct for the getaddrinfo call struct addrinfo hints, *res; memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // Fill in addrinfo with getaddrinfo if (getaddrinfo(NULL, "0", &...

what is the alternate way of doing function of switch-case (and if-else) in c?

what is the alternate way of doing function of switch-case (and if-else) in c? ...

Get the topmost window of my own application ONLY - in C

I'm using the following code to get a handle of the topmost window: HWND hwnd; hwnd = GetForegroundWindow(); The problem with this is that it returns the top most system-wide. Is there any way to get the topmost ONLY from my own application? I want to get the top most window ONLY of my application. This means, that I need an API to ...

Live RX and TX rates in linux

I'm looking for a way to programatically (whether calling a library, or a standalone program) monitor live ip traffic in linux. I don't want totals, i want the current bandwidth that is being used. I'm looking for a tool similar (but non-graphical) to OS X's istat menu's network traffic monitor. I'm fairly certain something like this ex...

Flow control Sliding window implementation. Which is better static-queue(array) vs dynamic linked-list?

I am implementing a sliding window for a trivial protocol. I was implementing the window using a static circular queue (array), as i though it is efficient. But one of my friends said, he has seen the implementation of sliding window in tcp, it uses a linked list. I dont think he has seen, as he doesnot know where is network code located...

Dependency resolution in Linux

Hi, Under Windows I have used a program called dependency walker to examine the libraries the application is using. I was wondering how I can achieve this on Linux for a standard binary: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.0, stripped Thanks. ...

How would you count the number of bits set in a floating point number?

How do you count the number of bits set in a floating point number using C functions? ...

Large C macros. What's the benefit?

I've been working with a large codebase written primarily by programmers who no longer work at the company. One of the programmers apparently had a special place in his heart for very long macros. The only benefit I can see to using macros is being able to write functions that don't need to be passed in all their parameters (which is r...

Counting the number of files in a directory using C

How can I count the number of files in a directory using C on linux platform. ...