hi, i want to write a program who do a simple encrypt on a txt file below i put my questions. sorry for my bad english. if I forgot some library or did I put too much pots on me? Thanks for help.
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
void c(string &x)
{
char a;
int i=0;
do{
a=x[i];
a++;
x[i]=a;
i++;
}while(a!='/');//how can i understand when to finish this while?
}
int main()
{
int i=0, b;
constint n=100000;//there is a const bigger which i can use?
string a[n];
string s;
cout<<"0"<<endl;
ifstream f("ps1.txt");
while(f.good())
{
getline(f, s);
a[i]=s;
i++;
}
f.close();
b=i;
i=0;
fstream f1("p1s.txt", ios::app);
while(i<=b)
{
c(a[i]);
s=a[i];
//how can I let the program automatically insert new
//strings into the file?
f1<<s<<endl;
i++;
}
f1.close();
system("pause");
return 0;
#include <iostream>
#include <string>
usingnamespace std;
void c(string &x)
{
for ( auto& a : x) // for each element in the string
{
a++; // increment the element
}
}
int main()
{
string x;
cin >> x;
c(x);
cout << '\n' << x;
}
<limits> has the largest constants for various integers. Or you can just know that an integer can hold 2 to the N-1 where n is the # of bits, so a 32 bit integer can hold 2 to the 32 -1 (unsigned).
not sure what exactly you are asking about inserting new strings.
playing around, casual home-use encryption, its hard to beat using xor on each byte of the file. But that tends to produce binary files, so the encrypted data can't be read with a text editor. Decrypted is unchanged of course, whatever the original was.
for autonomous way I meant I would want the subject to write a text file with information opens the program and the crypta program by itself the file.txt, the method I thought is the following: the file saves all the files strings inside a strings array of crypts and then rewrites them on the text file, and this must happen without any input from the subject.