Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6188233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:11:51+00:00 2026-05-24T02:11:51+00:00

I have written a password program in c. and I saved the password in

  • 0

I have written a password program in c. and I saved the password in a text file using some encryptiion and retrieving the old password from a file using decryption techniques So that user cannot see the password.Yes ofcourse this might not be the efficient way to do because there is a chance for user to delete the text file.

But still I want to lock (protect) a file using my c password code.I have searched on google I found perl can be used to lock a file.The question is that possible in c? Do we have any function like flock in perl? or suggest me some functions that can be helpful to develop a file lock function in c.becuase People may say we have c# and lots of stuff out to lock a file and why your sticking to c? but I like challenging the things.So please let me know If theres something I need to learn.Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:11:52+00:00Added an answer on May 24, 2026 at 2:11 am

    You can, on a POSIX system, use fcntl() along with the F_SETLK value for the command argument, and then set F_WRLCK (i.e, and exclusive lock) in the struct flock data-member l_type.

    So for instance (add your own error-detection mechanisms):

    #include <fcntl.h>
    #include <unistd.h>
    
    struct flock fl;
    int file_descriptor;
    int file_length;
    
    fd = open("my_password_file", O_RDWR);
    
    //... get the length of the file and set the variable file_length
    
    fl.l_type = F_WRLCK;
    fl.l_whence = SEEK_SET;
    fl.l_start = 0;
    fl.l_len = file_length;
    
    //set the exclusive-lock on the file
    fcntl(fd, F_SETLK, &fl);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file that ends with .vbs that I have written the
I'm using NUnit and TeamCity and I have written some system tests with descriptions.
I have written an AIR Application that downloads videos and documents from a server.
I have written some code in my VB.NET application to send an HTML e-mail
I've written an encryption program that encrypts and decrypts selected files using a user-entered
I have written this random password script which works perfectly. Although I would like
I have 3 classes that I have written some part of them below.when i
I have written a code and executes well I provide it username and password
I have written REST web service in netbean IDE using jersey framework and java.
Hey I have a program written exclusively in Java where users can make a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.