That read a text file and then extract it's words and store them in another text file each words in a separates line
ارجو المساعده ضروري
That read a text file and then extract it's words and store them in another text file each words in a separates line
ارجو المساعده ضروري
جربى هذا الكود::::::::::
#include <iostream.h>
#include <fstream.h>
void main ()
{
// opening the source file
ifstream file1 ("f1.txt",ios::binary);
if (!file1)
{
cout<<"cannot open file";
return;
}
// creating the destination file
ofstream file2 ("f2.txt",ios::binary);
if (!file2)
{
cout<<"can not create file";
return;
}
char ch;
while (!file1.eof())
{
file1.get(ch);
if(ch==' ' ){
cout<<endl;
}
file2.put(ch);
}
file1.close();
file2.close();
}و لا تنسى ان تضعى المسار الصحيح للملف تبعك....بالتوفيق
تم تعديل هذه المشاركة بواسطة نفرتاري في 14 أكتوبر 2010 في 21:15


#include <fstream>
#include <string>
#include <iterator>
#include <algorithm>
using namespace std;
typedef istream_iterator<string> input_i;
typedef ostream_iterator<string> output_i;
int main()
{
ifstream input_file("input.txt");
ofstream output_file("words_list.txt");
copy(input_i(input_file), input_i(), output_i(output_file, "\n"));
}Using the following file as an example:
Hello to arabteam2000-forumThis was your first question which was too vague to interpret exactly what you meant Next time please be more specific about your requirements
produces the following file:
Helloto arabteam2000-forum This was your first question which was too vague to interpret exactly what you meant Next time please be more specific about your requirements