我刚刚开始编程,但我有很多关于如何通过制作从文件读入内存时映射数据地址的程序解析文件时,使我的生活更轻松的想法。C++存储地址列表以解析原始非终止文本数组?
注:我砍倒墙上的文字,这里的问题简而言之
一个人如何解析字符数组没有空终止,但话全部用大写字母开头这样资本可以作为分隔符?
基本上我想解析只是'WordWordWord'的文本文件,并将每个单词发送给它自己的单独字符串变量,然后就可以将每个单词写入到添加了新行的文本文件中。
我想做一些更高级的东西,但我被要求削减文本的墙,这样会为现在做:)
//pointers and other values like file opening were declared
int len = (int) strlen(words2);
cout << "\nSize of Words2 is : " << len << " bytes\n";
// Loops through array if uppercase then...
for (int i = 0; i < len; i++)
{
if (isupper(words2[i]))
{
// Output the contents of words2
cout << "\n Words2 is upper : " << words2[i] << "\n";
b1 = &words2[i];
//output the address of b1 and the intvalue of words2[var]
cout << "\nChar address is " << &b1 << " word address is " << (int) words2[i] << "\n";
cout << "\nChar string is " << b1 << " address +1 "<< &b1+1 <<"\n and string is " << b1+1 << "\n";
}
cout << "\nItem I is : i " << i << " and words2 is " << words2[i] << "\n";
}
fin.clear();
fin.close();
fout.close();
缩短你的文字。我不想浪费时间阅读这一切:)和因为没有人回答我想我不是唯一一个......写得简短明了;并举例说明.. – duedl0r