C++は1行1行のテキストを読む

4549 ワード

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">
int main()</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">{</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">
</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   cout<<"input the filename:"<<endl;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   string filename;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   cin>>filename;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   ifstream infile(filename.c_str());</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   string temp;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   while(getline(infile,temp))</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   {</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   cout<<temp<<endl;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">   }</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">    cout << "Hello world!" << endl;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">    return 0;</p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(51, 51, 51); font-family: arial,   , sans-serif, 'Microsoft YaHei', tahoma; font-size: 14px; line-height: 24px; background-color: rgb(241, 254, 221);">}</p>