c

Error receiving in UDP: Connection refused

i am trying to send a string HI to a server over UDP in a particular port and trying to receive a response. however, after i try to get the response using recvfrom() i was stuck in blocking state. i tried using connected udp but i got Error receiving in UDP: Connection refused what could be the reasons for this. the server i not i...

random number generator

I need help on which random number generator to use simultaneously from multiple threads and get less execution time ...

Due to Shared memory, when MS Visual C 6.0 DLL crashes it also causes VB 6 EXE to crash

I have a problem where Due to Shared memory, when MS Visual C 6.0 DLL crashes it also causes VB 6 EXE to crash. Our main program EXE is written in VB 6. It calls plug-ins (DLL's) for the various file types, these are written in MS Visual C 6.0. When a "C" plug-in (DLL) encounters a problem it some times crashes and this causes the EXE pr...

Triple checked locking?

So in the meanwhile we know that double-checked-locking as is does not work in C++, at least not in a portable manner. I just realised I have a fragile implementation in a lazy-quadtree that I use for a terrain ray tracer. So I tried to find a way to still use lazy initialization in a safe manner, as I wouldn't like to quadruple memory ...

ubuntu webkit install

i'm new to ubuntu and i want to install webkit 1.0 as dev version but i don't know what i have to do ? ...

How much can this c/c++ loop be optimized?

I am a newbie on optimization. I have been reading some reference on how to optimize c++ code but I have a hard time applying it to real code. Therefore I just want to gather some real world optimization technique on how to squeeze as much juice from the CPU/Memory as possible from the loop below double sum = 0, *array; array = (double*...

Unified Parallel C - examples and list of extensions

Hello Where can I find examples of code, written in "Unified Parallel C"? I also interested in normative documents about this language (standards, reference manuals, online-accessible books and courses). What extensions were added to C to get UPC? Is this dialect alive or dead? ...

Reading one line at a time in C

Which method can be used to read one line at a time from a file in C. I have used fgets function also. but it's not working. it's reading space separated token only... What to do ??? ...

Is it possible to read in a string of unknown size in C, without having to put it in a pre-allocated fixed length buffer?

Is it possible to read in a string in C, without allocating an array of fixed size ahead of time? Everytime I declare a char array of some fixed size, I feel like I'm doing it wrong. I'm always taking a guess at what I think would be the maximum for my usecase, but this isn't always easy. Also, I don't like the idea of having a smalle...

What is the best alternative to calling strlen() in my for loop condition in C?

I've read that it is bad practice to call strlen() in my for loop condition, because this is an O(N) operation. However, when looking at alternatives I see two possible solutions: int len = strlen(somestring); for(int i = 0; i < len; i++) { } or... for(int i = 0; somestring[i] != '\0'; i++) { } Now, the second option seems...

passing parameters to unmanaged C api from vb.net

I need to call a function in an unmanaged .dll written in C lang from vb.net. The function declaration looks like this LONG _stdcall ReadInfo(char *reply); Now the behavior of this function is that it copies some data in argument "reply" and returns a numeric value which signals its pass/fail status. How do i pass it a string object so...

What are the possible pitfalls in porting Psyco to 64-bit?

The Psyco docs say: Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom Python in 32-...

How stupid it is to use an integer value a key for an Hash Table?

Hi, I'll be needing to use Hash Tables with different keys. One as string for the key and another as integer. As for the integer one, how stupid it is to run a hash function on the number to generate a key? I mean, the numbers I'll be using as key for the Hash Table will always be different, there will be no duplicates at all. Isn't e...

What is wrong with this arithmetic when using SDCC (Little Endian) Compiler?

I am very new at C programming and I am working on a firmware application for my MCU. This method was working fine when I was using the KEIL compiler (Big Endian) but when I switched to the SDCC compiler (Little Endian) it is not working properly. Can someone please explain what I am doing wrong??? The target device is a Silicon Labs C8...

Aligning doubles on 8-byte boundaries?

Is there a common portable idiom in numerics code (I'm writing in D, but language-agnostic, C and C++ answers would be useful to me, too) to ensure that all stack-allocated doubles that are accessed frequently are aligned on 8-byte boundaries? I'm currently optimizing some numerics code where misaligned stack-allocated doubles (only ali...

Should I declare the expected size of an array passed as function argument?

I think both is valid C syntax, but which is better? A) void func(int a[]); // Function prototype void func(int a[]) { /* ... */ } // Function definition or B) #define ARRAY_SIZE 5 void func(int a[ARRAY_SIZE]); // Function prototype void func(int a[ARRAY_SIZE]) { /* ... */ } // Function definition ...

forcing fgets to block (i.e. faking an "interactive device")

Hi, I have a C application which provides a "shell" for entering commands. I'm trying to write some automated test-code for the application (Using CUnit). The "shell" input is read from stdin like so: fgets(buf, sizeof(buf), stdin); I can "write" commands automatically to the application by freopen()'ning stdin and hooking it to an i...

Writing contents of file using Create/ReadFile - C

Hello, I'm trying to read the contents of a small text file using the common dialog box, pass the text in the file into a buffer and draw it to the form by invalidating the window and forcing the repaint. Everything works with exception to displaying the text on the screen, when I click on the OK button on the dialog box no text appear...

how to find the header file to be included for a library function in linux

Given a function, let's say atoi, how can I find the header file I should include if I want to use this function ? I'm always get puzzled for that issue. If let me treat function like "atoi" as linux c api, I can put my question in another way as : Is a document for linux c api ? ...

Does lwIP support Zeroconf?

I see that lwIP has some AutoIP (aka IPv4LL, aka RFC 3927) code, but I can't tell if it does anything higher up in the Zeroconf stack, namely mDNS and DNS-SD (with RFC 2782). So, does lwIP support DNS-SD service discovery? If not, would it be easy to port code from a project like Avahi that does (assuming licensing allows it)? ...