answersLogoWhite

0

C code to implement file locking?

User Avatar

Anonymous

12y ago
Updated: 8/18/2019

#include <stdio.h>

#include <errno.h>

#include <fcntl.h>

int fd;

/* file descriptor */ char *filename;

main(argc,

argv)

int argc;

char *argv[];

{ extern

void exit(), perror();

/* get database file name from command line and open the * file for read and write access. */ if (argc

< 2) { (void) fprintf(stderr,

"usage: %s filename\n",

argv[0]); exit(2); } filename

=

argv[1]; fd

=

open(filename,

O_RDWR);

if (fd

< 0) { perror(filename);

exit(2); } }

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

C code to implement the file allocation algorithm?

yes we can do it,in c


How do you Open a text file as C plus plus source code?

All C++ source code is is a text file with the .cpp extension. So if you save your code as *****.cpp then it is automatically C++ source code.


How do you convert .c extension to .exe?

To convert source code (.c file) to an executable (.exe) file you have to use a compiler, which is a translator of source code to machine code.


What is a source code file in c plus plus?

A source code file is a plain-text file containing C++ instructions. The instructions must be compiled and linked to create a native machine code executable.


How do you create a header file and implementation of code in another c file and both should be retrieved by another .c file?

tanga


How do you create a new C source file?

A source file is nothing more than a text file with code. Therefore, any file created in Notepad and saved as "anyname.c" is considered a C source file.


What header file used in c code to directly access the printer?

No such thing in standard C library.


A function is declared in C header file When you try to implement in a c source file it is giving error?

The source file must include the header file. Beyond that we can only guess at the problem without seeing the content of the source and header files. Do not post the files here. Such questions are better handled by the many C programming forums available elsewhere on the Internet.


What is the VHDL code to implement NOR gate?

Below code can implement NOT gate in VHDL. The code is written in data flow model. Library ieee; use ieee.std_logic_1164.all; Entity gates is port (a : in std_logic; c : out std_logic); end gates ; architecture and1 of gates is begin c&lt;=not a; end and1;


C program download a file from HTTP server source code?

curl, wget


Which directories should be entered for graphics code in c?

use grphics.h header file


How do you copy c program to msword?

If you want to copy C source code to a new file in MS Word, use the following steps:Open the C program in Notepad if it's not already open.Select all text (usually CTRL+A works fine).Copy that text to the clipboard (CTRL+C).Open MS Word (or Wordpad).CTRL+V to paste the C source code.Save if desired.If the C source code is in a file, and you have Windows Explorer open with that file showing, you can open MS Word, and then drag the file from Explorer to MS Word, which will open that file.