منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] محتاج مساعده - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغات البرمجة الاخرى (http://vb4arb.com/vb/forumdisplay.php?fid=4)
+--- قسم : قسم لغة ++C (http://vb4arb.com/vb/forumdisplay.php?fid=19)
+--- الموضوع : [سؤال] محتاج مساعده (/showthread.php?tid=19234)



محتاج مساعده - ayuob - 14-02-17

كيف استطيع ان افتح ملف txt واختار نص معينه منه واجراء عمليه حسابية والاخراج كل المدخلات بعد التعديل في ملف txt


RE: محتاج مساعده - dasktop - 17-11-18

تفضل اخي كود تعبئة وتعديل مستند txt


كود :
#include <iostream>
#include <fstream>
using namespace std;

int main () {
 ofstream myfile ("example.txt");
 if (myfile.is_open())
 {
   myfile << "This is a line.\n";
   myfile << "This is another line.\n";
   myfile.close();
 }
 else cout << "Unable to open file";
 return 0;
}


وهاذا كود لمعرفة حجم اي ملف


كود :
#include <iostream>
#include <fstream>
using namespace std;

int main () {
 streampos begin,end;
 ifstream myfile ("example.bin", ios::binary);
 begin = myfile.tellg();
 myfile.seekg (0, ios::end);
 end = myfile.tellg();
 myfile.close();
 cout << "size is: " << (end-begin) << " bytes.\n";
 return 0;
}