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 7569351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:08:38+00:00 2026-05-30T15:08:38+00:00

I have basic code that looks like this: while(inputfileStream.good()) { for(int i = 0;i<levels;i++)

  • 0

I have basic code that looks like this:

while(inputfileStream.good())
{
    for(int i = 0;i<levels;i++)
    {
        inputfileStream.open(_file,ios::in | ios::out | ios::binary);
        for(int i = 0,kPOS=0;i<=fsize;i++,kPOS++)
        {
            if(kPOS > Ksize)
                kPOS=0;
            char tempchar = 0;
            inputfileStream.seekg(i,ios::beg);
            inputfileStream.get(tempchar);
            tempchar+=(int)_encription_key[kPOS];
            inputfileStream.seekg(i,ios::beg);
            inputfileStream.put(tempchar);
        }
        inputfileStream.close();
    }
}

It’s a basic encrypter. I just have one problem: For each level of encryption I have to reopen the file to get its contents. Otherwise if I do not do this I have the same old text when I decrypt the file from each level.

Could you help me out and give a more efficent way of rereading the files contents besides calling open() and close()?

  • 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-30T15:08:39+00:00Added an answer on May 30, 2026 at 3:08 pm

    Instead of closing and opening the file, you can

    1. flush() the written content
    2. sync() the content to the read buffer
    3. seekp() the put pointer to the start of the file on each iteration

    This may be clearer to you if you set exceptions() on your fstream. You are most likely not seeing your encryption working at some points due to the fstream not being in the good() state.

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

Sidebar

Related Questions

I have a basic socket server that looks like this: IPEndPoint localEndPoint = new
I have a very basic XML file that looks like this: <allData> <allDataDetails> <quoteid>ABC123</quoteid>
I have a DOM situation that looks like this: A is an ancestor of
I have some very basic semaphore code that works great on Linux, but cannot
I have been struggling with this a while now. I implemented a basic IHttpHandler
While I have made a topic like this in the past, this is from
I have the basic code to rewrite a subdomain to another page. But how
Currently, I have some basic code to play a simple tone whenever a button
I have some basic PHP code: $raceramps56[short] = My Test Product; $leftMenu = '<div
I have a basic PHP question, take the code below for example, let's say

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.