请教如何做到识别其中段落与段落间的空行

ithiker 2010-10-07 12:23:44
C++如何做到识别其中段落与段落间的空行
空行判断时怎样写:if(line == " ")好像不可以
我的程序,帮忙改写下:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main(void)
{
ifstream file_in;
file_in.open("abc.txt");
string sLine;
int n=0;

while(getline(file_in,sLine))
{
cout<<n++<<" ";
if(sLine == " ")
cout<<"空行";
cout<<sLine<<endl;
}
file_in.close();

return 0;

}

When on board H.M.S. Beagle, as naturalist, I was much struck with certain
facts in the distribution of the organic beings inhabiting South America,
and in the geological relations of the present to the past inhabitants of
that continent. These facts, as will be seen in the latter chapters of
this volume, seemed to throw some light on the origin of species--that
mystery of mysteries, as it has been called by one of our greatest
philosophers. On my return home, it occurred to me, in 1837, that
something might perhaps be made out on this question by patiently
accumulating and reflecting on all sorts of facts which could possibly have
any bearing on it. After five years' work I allowed myself to speculate on
the subject, and drew up some short notes; these I enlarged in 1844 into a
sketch of the conclusions, which then seemed to me probable: from that
period to the present day I have steadily pursued the same object. I hope
that I may be excused for entering on these personal details, as I give
them to show that I have not been hasty in coming to a decision.

My work is now (1859) nearly finished; but as it will take me many more
years to complete it, and as my health is far from strong, I have been
urged to publish this abstract. I have more especially been induced to do
this, as Mr. Wallace, who is now studying the natural history of the Malay
Archipelago, has arrived at almost exactly the same general conclusions
that I have on the origin of species. In 1858 he sent me a memoir on this
subject, with a request that I would forward it to Sir Charles Lyell, who
sent it to the Linnean Society, and it is published in the third volume of
the Journal of that Society. Sir C. Lyell and Dr. Hooker, who both knew of
my work--the latter having read my sketch of 1844--honoured me by thinking
it advisable to publish, with Mr. Wallace's excellent memoir, some brief
extracts from my manuscripts.

This abstract, which I now publish, must necessarily be imperfect. I
cannot here give references and authorities for my several statements; and
I must trust to the reader reposing some confidence in my accuracy. No
doubt errors may have crept in, though I hope I have always been cautious
in trusting to good authorities alone. I can here give only the general
conclusions at which I have arrived, with a few facts in illustration, but
which, I hope, in most cases will suffice. No one can feel more sensible
than I do of the necessity of hereafter publishing in detail all the facts,
with references, on which my conclusions have been grounded; and I hope in
a future work to do this. For I am well aware that scarcely a single point
is discussed in this volume on which facts cannot be adduced, often
apparently leading to conclusions directly opposite to those at which I
have arrived. A fair result can be obtained only by fully stating and
balancing the facts and arguments on both sides of each question; and this
is here impossible.

...全文
100 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
cswuyg 2010-10-07
  • 打赏
  • 举报
回复
双引号中不要加空格
cswuyg 2010-10-07
  • 打赏
  • 举报
回复
汗……
判断空行是这样的:if(line == "")
dxms8 2010-10-07
  • 打赏
  • 举报
回复
按行取string,判是否为空?
Zeecool 2010-10-07
  • 打赏
  • 举报
回复
不懂,帮你顶下

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧