Jump to content
Fani

C++

Recommended Posts

Posted

Salutare

mi`am facut un program c++ care sa`m genereze toate caracterele posibile de la un caracter pana la cate caractere vreau eu , am ajuns`i dau n=1 si a[1]=6 si el sa`m genereze ca`m 2.3 Gb de caractere , as vrea sa stiu daca se poate si exista ceva in c++ care m`ar ajuta sa` impart acel 2.3 Gb in mai multe fisiere , adica fiecare fisier sa aiba 500 mb , in cazul de fata sa`m faca 5 fisiere , respectiv 4 de 500 mb si unu de 3 sute mb , ms mult , astept raspuns

Posted

Nu stiu la ce te ajuta, dar na.

numara orice salvezi.

folosesti functia asta


unsigned long nr = 0;
short files_nr = 0;
fstream file;
bool start = false;
void write(string text)
{
if(!start)
{
string filename = "data"+ToString(files_nr++)+".txt";
file.open(filename.c_str(),ios::out);
start = true;
}
else
{
if(nr >= 524288000)
{
start = false;
nr = 0;
file.close();
}
else
{
file<<text.c_str();
nr+=strlen(text.c_str());
}
}
}

iar functia ToString e cam asa


string ToString(int numar)
{
//#include <sstream>
stringstream out;
out << numar;
return out.str();
}

Testeaza si zi-mi daca iti merge.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...