سرریزی بافر در فایل ها در سی پلاس پلاس

mhabat

Member
سلام کد زیر هم مربوط به سرریزی بافر هست که در قسمت فایل ها رخ می دهد.
سورس:
کد:
// print the content of a text file.#include <iostream>#include <fstream>#include <string>using namespace std;int main () { // This is where we'll put the stuff we read from file  char buffer[ 50000 ];  // Fill the buffer with zeros (char strings must be null-terminated)  fill_n( buffer, 50000, '\0' );  ifstream infile;  infile.open ("myfile.txt", ifstream::in);ofstream                   fFile;fFile.open("myfile3.txt", ofstream::out);    while (infile.good())  {	// Read as many as 100 bytes (chars) from the file and stick them in our array  infile.read( buffer,  50000);  // Convert that char array into a STL string, and show the user what we got.  string g( buffer );   	string str2="fr3y.txt";	string str="fr3y1.txt";		 	g.replace(g.find(str2), str2.length(), str);	cout << g << " successfully read from file.\n";fFile << g << endl;   infile.close();fFile.close();  }   return 0;}
اگر میشه لطف کنید قسمت های مربوط به دستور های فایل ها مثل:
ofstream::eek:ut
یا
ifstream::in
(دو نقطه)
رو توضیح بدین.
وقسمت مهم اینکه چه کار کنیم که بافر سر ریز بشه؟تعداد پارامتر ها چه اندازه باید باشه؟
و همچنین برای جلوگیری ازین رخداد چه کاری باید انجام داد؟

خیلی ممنون
 

جدیدترین ارسال ها

بالا