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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:42:13+00:00 2026-06-03T05:42:13+00:00

I am trying to make simple encryption algorithm .My aim is to translate abc

  • 0

I am trying to make simple encryption algorithm .My aim is to translate abc (it can be any word) to 123. Then apply some functions then again translate to text, Here is my algorithm .I have problem about filing.I create unencrypted.txt which is written inside “hello world” then debug program it s creating encrypted.txt but just written w o r l d.why it s not writing hello world.always takes last word and with spaces “w o r l d”,Can you help me?

Edit
https://www.dropbox.com/s/i3afkm439iv3d0v/last%20form.txt this is the last form i added multply 2 and mod 27 for encryption.it works better.but still problem.there is “hello world” in txt file.its encryption
pjxxcpjxxcpjxxcpjxxcscixhpjxxcqscixhqpjxxc scixh
but it must be pjxxc scixh

   #include <cstdlib>
    #include <iostream>
    #include<stdio.h>
    #include<string.h>
    #include <conio.h>



    int main()
    {   
        int g,p,sak,v,r,t,z,o,c,l,i,j,k,*D;


    char alfabe[27]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\0'}; 
     FILE *fp1;
     FILE *mat;
       char word[20];

       fp1 = fopen("unencrypted.txt","r");
       do {
          g = fscanf(fp1,"%s",word); /* dosyadan bir kelime oku... */
          if (g != EOF) {
                mat=fopen("encrypted.txt","w") ;


        c=strlen(word);
        printf("has %d letters ", c);
        D = (int *) malloc( sizeof(int)*c ); 
        for(i=0;i<c;i++) {
            for(j=0;j<26;j++) {
                if(word[i]==alfabe[j]) {  
                     D[i]=(j+1);

                     break;
                }
            }
        }




         printf("\nlast form before translation ");
         for(l=0;l<c;l++) {
           printf("%d",D[l]);  /*it s just for control */

        }
        for(z=0;z<c;z++){

                          o=D[z];
                          word[z]=alfabe[o-1] ;  }   





        printf("\nnew form of word: ");
        for(k=0;k<c;k++) {

           fprintf(mat," %c",word[k]);

        }
    fclose(mat);
    }


    } while (g != EOF);          
       fclose(fp1);   }
  • 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-03T05:42:14+00:00Added an answer on June 3, 2026 at 5:42 am

    You are opening the file for writing inside the loop:

    do {
        ...
        mat=fopen("encrypted.txt","w") ;
        ...
        // writing to file
        ...
        } while(g != EOF);
    

    as a result each iteration of the loop will wipe off the old file contents.

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

Sidebar

Related Questions

I'm trying to make a simple encryption program with C. My aim is to
Trying to make a simple toggle menu, and I can't seem to hide/show the
I'm trying make a simple control, with a some path in it. And binding
I'm trying to make a simple search box. How can I trigger a function
I'm trying to make simple http server, that can be pause and resume,, I've
Trying to make simple minesweeper game in python, but have one problem. I have
I am trying to make simple notepad application for learning android development. So, to
I'm trying to make simple script using jquery $post function to pass data to
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:

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.