我想输入一个包含Urdu单词的文件,并将其写入其他文件中。我面临的问题是乌尔都语语言没有空格,因此编写的其他文件看起来与所有相互连接的单词相似。我如何分隔单词或检测空格?我的代码是这样的。
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
ifstream file;
ofstream myfile;
file.open ("urduwords.txt"); //File containing Urdu words
myfile.open("urduoutput.txt"); // Output file
if (!file.is_open()) return;
char * word= new char[];
while(file>>word)
{
myfile<<word;
// What to write here to separate words or detect spaces. Input file is saved in UTF-8
}
myfile.close();
file.close();
cout<<"Check output"<<endl;
}
答案 0 :(得分:0)
哦,我得到了答案。答案是你必须在乌尔都语字符之间放置空格,因为乌尔都语语言有空间省略问题所以在while循环
while(file>>word)
{
myfile<<word;
myfile<<" "; // Put spaces between words.
}