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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:14:16+00:00 2026-06-03T01:14:16+00:00

#include <Windows.h> #include <cstdio> const int KEY=111; void encryptStrA(char* sometext) { int length; length=strlen(sometext);

  • 0
#include <Windows.h>
#include <cstdio>
const int KEY=111;

void encryptStrA(char* sometext)
{
    int length;
    length=strlen(sometext);
    for(int i=0; i<length;i++)
        sometext[i]^=KEY;
}

int main(void)
{   
    FILE* pFile=fopen("pliczek","wb");
    char sign;
    char sampleString[]="Hello world!";

    encryptStrA(sampleString);
    fprintf(pFile,"%c%c%s%c%c",13^KEY,10^KEY,sampleString,13^KEY,10^KEY);
    fclose(pFile);

    pFile=fopen("pliczek","rb");
    while(!feof(pFile))
    {   
        fscanf(pFile,"%c",&sign);
        printf("%c",sign^KEY);
    }

    fclose(pFile);
    system("PAUSE");
    return 0;
}

I evaded some tricky things

  1. File is opened in binary mode
  2. In encryptStrA strlen function isn’t placed directly in the loop condition

In spite of these, it still has been outputting “Hell” instead of “Hello World!”? More precisely, cuts everything after spotting the key character .What’s the reason? I use OS in which every line of text is ended with carriage return(ASCII 13) and line feed (10).

  • 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-06-03T01:14:19+00:00Added an answer on June 3, 2026 at 1:14 am

    The code fprintf("%s", s); expects s to be a zero-terminated string. When you reach 'o'^111 it gives a null character, so the rest of the string is not written to the file.

    You can use fwrite instead.

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

Sidebar

Related Questions

#include stdafx.h #include string.h #include windows.h bool SCS_GetAgentInfo(char name[32],char version[32], char description[256], const char
#include <algorithm> #include <Windows.h> int main() { int k = std::min(3, 4); return 0;
When trying to compile a file that include winnt.h via windows.h, I get the
I was under the impression that this code #include <windows.h> #include <stdio.h> int WINAPI
And I can't figure out why. My code: #include <windows.h> #include <commctrl.h> #include <cstdio>
#ifndef UNICODE #define UNICODE #endif #include <Windows.h> #include <cstdio> TCHAR* getSystemVolumine() { TCHAR volumine[2];
/*language C code*/ #include windows.h typedef struct object_s { SRWLOCK lock; int data; }
I just needed to include windows office 2010 Ribbon bar into my C# application(Not
I'm looking to include a Windows .exe in my gem and call on that
I am experimenting with Beep function on Windows: #include <windows.h> ... Beep(frequency, duration); The

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.