c

Volume Shadow Copy Service (VSS) sample in C?

I been trying to read the documentation for the API functions of Volume Shadow Copy Service, for the purpose of copying files that are currently locked (being used) under Windows XP. Unfortunately I don't seem to get nowhere. Anybody happen to have a code sample of how to interact with the API, for copying such files? Thanks, Doori Bar...

Interrupt mechanism in C,C++

Hey I was writing a udp client server in which a client waits for packets from server.But I want to limit this wait for certain time.After client don't get response for a certain moment in raise an alarm,basically it comes out and start taking remedy steps.So what are the possible solution for it.I think writing a wrapper around recv wil...

Is it ok to return a reference of a function scope static variable?

I wanted to know if that has any ill effects under any circumsatnce. For ex: Ex1: void* func1() { void* p_ref = NULL; //function scope static variable static int var1 = 2; p_ref = &var1; return p_ref; } Ex2: //file scope static variable static int var2 = 2; void* func2() { void* p_ref = NULL; var2 = 3; p_ref =...

Multiple declarations and definitions

Content of X.c: int i; main () { fun (); } Content of Y.c: int i; fun () { } Why does these two files compile with no error ? (using GCC) But if i use int i = 10; it prints a multiple definition error. ...

Interesting task using random numbers only

Given any number of the random real numbers from the interval [0,1] is there exist any method to construct a floating point number with zero fractional part? Your algorithm can use only random() function calls and no variables or constants. No constants and variables are allowed, no type casting is allowed. You can use for/while, if/el...

Strange realloc behaviour

Hi guys, i'm developing an array structure just for fun. This structure, generalized by a template parameter, pre allocates a given number of items at startup, then, if "busy" items are more than available ones, a function will realloc the inner buffer . The testing code is : #include <stdio.h> #include <stdlib.h> #include <string.h> t...

Declaration, allocation and assignment of an array of pointers to function pointers

Hello Stack Overflow! This is my first post, so please be gentle. I've been playing around with C from time to time in the past. Now I've gotten to the point where I've started a real project (a 2D graphics engine using SDL, but that's irrelevant for the question), to be able to say that I have some real C experience. Yesterday, while w...

In what language was MSDOS originally written?

In what language was MSDOS originally written in? The Wikipedia Article implies either C, QBasic or Pascal, but: C was invented to write UNIX, so I don't believe it was used to write MSDOS Pascal seems popular to teach programming, but not really popular to write Operating systems in QBasic didn't seem to be very popular for Operating...

SysRc enum values in c c++

i am working on a project where i am using SysRc values as return values from some function like SUCCESS and FAILURE ond sum enums . Now i want to know how to get them print? ...

Fastest method to define whether a number is a triangular number

A triangular number is the sum of the n natural numbers from 1 to n. What is the fastest method to find whether a given positive integer number is a triangular one? ...

Ways not to write function headers twice?

Hi, I've got a C/C++ question, can I reuse functions across different object files or projects without writing the function headers twice? (one for defining the function and one for declaring it) I don't know much about C/C++, Delphi and D. I assume that in Delphi or D, you would just write once what arguments a function takes and then...

Get PE and VA of executable file with C

I want to write a little program in C to extract the PE (Entry Point) and VA (Virtual Address) of a COFF executable. How can I do that? ...

How can I get the telnet result using C / Objective C?

Here is a telnet site: telnet://202.85.101.136:8604/ It is from Hong Kong public library, can I write some programme to get the string / result from the telnet service, and send the request from C / Objective C? thz u. ...

Including non-standard C headers in C++

I needed to include a few c headers ( non standard header files ) in my C++ code to be compiled by gcc. The C header (foo.h) has support for : #ifdef __cplusplus extern "C" { #endif and similarly at the end for }. The c++ code has the include "foo.h" I believe I should be able to just include the header (foo.h) and create instan...

Library for parsing arguments GNU-style?

I've noticed the basic 'style' of most GNU core applications whereby arguments are: --longoption --longoption=value or --longoption value -abcdefg (multiple options) -iuwww-data (option i, u = www-data) They follow the above style. I want to avoid writing an argument parser if there's a library that does this using the above style. I...

C Preprocessor: #define in C... advice

Hi Guys, I'm making a big C project and I have never come across a situation like this before so, I need your advice. What is your opinion? Is it okay to have the constants defined within conditional preprocessors like I have done below or you advise me to do this some other way? #define NUM_OCTAVES_4 //#define NUM_OCTAVES_5 #ifde...

What's the benefit of declaring class functions separately from their actual functionality?

In C++, what's the benefit of having a class with functions... say class someClass{ public: void someFunc(int arg1); }; then having the function's actual functionality declared after int main int main() { return 0; } void someClass::someFunc(int arg1) { cout<<arg1; } Furthermore, what's the benefit of declaring the...

Error while trying to reverse a char array

Hi, I'm trying to get better at C++ (I know a little). I'm working on character arrays. I found an exercise where the objective is to reverse a character array (after I convert it from an integer). I'm getting the following error (using VS2005): Run-Time Check Failure #2 - Stack around the variable 'revBuffer' was corrupted. When I ste...

i need a real time clock in ansi c which provide an accuracy upto miliseconds?

i need a real time clock in ansi c which provide an accuracy upto miliseconds? i am working on windows a windows base lib is also acceptable thanx in advance. ...

C code in Linux to C code in Windows

I'm having a code written in C that works on Linux. I want this program to work in windows, Are there any differences that I have to make in the code ? It is a code for Server/Client communication using sockets taken from here : http://www.linuxhowtos.org/C_C++/socket.htm ...