c

How to implement RFC 3393 (Ipdv packet delay varation) in C?

Hello , I am building an Ethernet Application in which i will be sending packets from one side and receiving it on the other side. I want to calculate delay in packets at the receiver side as in RFC 3393. So I have to put a timestamps in the packet at the sender side and then take the timestamps at the receiver side as soon as i receive ...

In C Programming, can I use multiply and divide to shift bits?

Instead of using >> and << to shift, is it posible to use * and / to shift left and right? for an 8-bit: 0x01*2 = 0000|0010? ...

How fast is MySQL compared to a C/C++ program running in the server?

Ok, I have a need to perform some intensive text manipulation operations. Like concatenating huge (say 100 pages of standard text), and searching in them etc. so I am wondering if MySQL would give me a better performance for these specific operations, compared to a C program doing the same thing? Thanks. ...

Why doesn't C have unsigned floats?

I know, the question seems to be strange. Programmers sometimes think too much. Please read on... In C I use signed and unsigned integers a lot. I like the fact that the compiler warns me if I do things like assigning a signed integer to an unsigned variable. I get warnings if I compare signed with unsigned integers and much much more. ...

Is there something that I can do in C but I can't do in C++ ?

Is there something that I can do in C but I can't do in C++ ? I stumbled upon the question in a sample interview questions site... ...

(How) Can I determine the socket family from the socket file descriptor

I am writing an API which includes IPC functions which send data to another process which may be local or on another host. I'd really like the send function to be as simple as: int mySendFunc(myDataThing_t* thing, int sd); without the caller having to know -- in the immediate context of the mySendFunc() call -- whether sd leads to a ...

libsox help

EDIT: i want to use libsox to programatically convert a wav file's sample rate, audio format, channels, and etc. in the libsox man page, there are a bunch of functions I can use but I'm clueless as hell on what to do. Can anyone give me a sort of steps on how to do it? Help? Can anyone please explain this? The function sox_w...

How does Duff's device work?

I've read the article on wikipedia, on the Duff's Device, and I don't get it. I am really interested, but I've read the explanation there a couple of times and I still don't get it how the Duff's device works. Can some one attempt at a more detailed explanation? Thanks ...

Is it more efficient to branch or multiply?

I am trying to optimize a small, highly used function which uses the high bits in an unsigned short int to indicate the values of an array to sum together. At first I was using the obvious approach shown below. Please note that loop unrolling is not explicitly shown as it should be done by the compiler. int total = 0; for(unsigned short...

How to open .ttcn file using C file open functions?

I am working on TTCN-3 (Testing and Test Control Notation) scripting language. I wanted to prepare on guideline checker for this code files. For that I want to read lines of TTCN-3 script file( some thing like file.ttcn ) one by one into a buffer. But for me fopen / sopen / open / fgetc / fscanf are not able to work properly and are not...

How to dynamically get the filename according to extension?

As a follow up to this question .... Now I found the answer for that quesstion by a comment by user j_random_hacker. Here Widnows follows 8.3 file naming standard means turbo c can only read files with name length of 8 characters and extension of 3 characters. So windows will give another name to any file which is not following 8.3 na...

convert an integer number into an array

Hi, I am trying to convert an integer number in C into an array containing each of that number's digits i.e. if I have int number = 5400 how can I get to int numberArray[4] where numberArray[0] = 0; numberArray[1] = 0; numberArray[2] = 4; numberArray[3] = 5; Any suggestions gratefully received --dave ...

Should I disable the C compiler signed/unsigned mismatch warning?

The Microsoft C compiler warns when you try to compare two variables, and one is signed, and the other is unsigned. For example: int a; unsigned b; if ( a < b ) { // warning C4018: '&lt;' : signed/unsigned mismatch } Has this warning, in the history of the world, ever caught a real bug? Why's it there, anyway? ...

When don't I need a typedef?

I encountered some code reading typedef enum eEnum { c1, c2 } tagEnum; typedef struct { int i; double d; } tagMyStruct; I heard rumours that these constructs date from C. In C++ you can easily write enum eEnum { c1, c2 }; struct MyStruct { int i; double d; }; Is that true? When do you need the first variant? ...

C/C++ linker CALL16 reloc at xxxxx not against global symbol

I'm getting these errors while linking, both messages have to do with the same object file. CALL16 reloc at 0x5f8 not against global symbol and could not read symbols: Bad value The 2nd message seems to be the reason I'm getting the CALL16 error, but the file compiles just fine. Any tips on fixing this? FYI, I'm cross compiling f...

Tools to get a pictorial function call graph of code

I have a large work space which has many source files of C code. Although I can see the functions called from a function in MS VS2005 using the Object browser, and in MSVC 6.0 also, this only shows functions called from a particular function in a non-graphical kind of display. Additionally, it does not show the function called starting f...

Linux & C: How to set file reading priority in multi-process program?

This is for an assignment I'm working on, and NO I'm not looking for you to just GIVE me the answer. I just need someone to point me in the right direction, maybe with a line or two of sample code. I need to figure out how to set the priority of a file read operation from within my program. To the point: server process receives a mess...

Good examples of C applications?

Everyone knows that C is hard to program in, provides you with almost no useful abstractions, and is even dangerous. However, given enough design and discipline, it's possible to write clean, portable, modular code. What are some good examples of this? I'm looking for real world applications or other open source projects that are reasona...

How to force parent window to draw "under" children windows?

The environment is plain-old win32 under C/C++ without any fancy MFC or similar mumbo-jumbo. I have a window, which has several children and grandchildren. Some children are oddly-shaped icons, and I need them to have transparent background (oddly-shaped icons). Consider a this pseudo-structure: Parent1 Child1 (normal) Child2 (oddly-s...

@synthesize-ing a C array of structs in Objective-C 2.0

I'm trying to follow a tutorial for a C++ interface in the Mac OS X API (Audio Queue Services), but in a Cocoa (well, actually just Foundation) application (well, actually just a 'tool'). It has a struct that looks like this: static const int kNumberBuffers = 3; // 1 struct AQPlayerState { AudioStreamBas...