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

  • Home
  • SEARCH
  • 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 6343519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:27:14+00:00 2026-05-24T20:27:14+00:00

I am new programmar in Ruby. Can someone take an example about opening file

  • 0

I am new programmar in Ruby. Can someone take an example about opening file with r+,w+,a+ mode in Ruby? What is difference between them and r,w,a?

Please explain, and provide an example.

  • 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-24T20:27:15+00:00Added an answer on May 24, 2026 at 8:27 pm

    The file open modes are not really specific to ruby – they are part of IEEE Std 1003.1 (Single UNIX Specification). You can read more about it here:

    http://pubs.opengroup.org/onlinepubs/009695399/functions/fopen.html

    r or rb
        Open file for reading.
    
    w or wb
        Truncate to zero length or create file for writing.
    
    a or ab
        Append; open or create file for writing at end-of-file.
    
    r+ or rb+ or r+b
        Open file for update (reading and writing).
    
    w+ or wb+ or w+b
        Truncate to zero length or create file for update.
    
    a+ or ab+ or a+b
        Append; open or create file for update, writing at end-of-file.
    

    Any mode that contains the letter ‘b’ stands for binary file. If the ‘b’ is not present is a ‘plain text’ file.

    The difference between ‘open’ and ‘open for update’ is indicated as:

    When a file is opened with update mode ( ‘+’ as the second or third character in the mode argument), both input and output may be performed on the associated stream. However, the application shall ensure that output is not directly followed by input without an intervening call to fflush() or to a file positioning function ( fseek(), fsetpos(), or rewind()), and input is not directly followed by output without an intervening call to a file positioning function, unless the input operation encounters end-of-file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a pretty new C# programmer. I was wondering if someone can fill me
I'm a new programmer, so please excuse any dumbness of this question, how the
I'm a fairly new programmer so please bear with me on this. I am
I am (quite) an experienced programmer but totally new to Ruby and Ruby on
Can't figure this one out. Done research, searched here, online, etc. Still a new
i am a new programmer in android application. how can i concatenate the value
I have a couple questions about Ruby's methods, procedures, and blocks that strike me
I'm trying to run the DelegateClass example from http://ruby-doc.org/stdlib/libdoc/delegate/rdoc/files/delegate_rb.html Here is the code: require
I am new to ruby but nonetheless I have installed various versions of Ruby
I'm playing with Ruby and learning about OO techniques and inheritance and I've finally

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.