Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

有關C++ iostream的問題~

0 views
Skip to first unread message

沒什麼好留戀的

unread,
Jan 22, 2000, 3:00:00 AM1/22/00
to

如果開檔案想要直接讀取裡面的interger而不經過atoi函數的話,該怎麼做呢?

課本上的例子都是:

// fstream.h included.

ifstream fin;
fin.open(filename);
while(fin.good())
{
while((ios&) fin.get(ch))
cout<<ch;
}

有直接就讀進integer的方法嗎?謝謝~

--
※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: u870624.YI.ab.nthu.edu.tw

天天都要有進步

unread,
Jan 22, 2000, 3:00:00 AM1/22/00
to
※ 引述《pchi (沒什麼好留戀的)》之銘言:

> 如果開檔案想要直接讀取裡面的interger而不經過atoi函數的話,該怎麼做呢?
> 課本上的例子都是:
> // fstream.h included.
> ifstream fin;
> fin.open(filename);
> while(fin.good())
> {
> while((ios&) fin.get(ch))
> cout<<ch;
> }
> 有直接就讀進integer的方法嗎?謝謝~


試試fscanf()吧!!
--
※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: alphapc4.cs.nthu.edu.tw

最近太墮落....

unread,
Jan 22, 2000, 3:00:00 AM1/22/00
to
※ 引述《pchi...@bbs.cs.nthu.edu.tw (沒什麼好留戀的)》之銘言:

: 如果開檔案想要直接讀取裡面的interger而不經過atoi函數的話,該怎麼做呢?
: 課本上的例子都是:
: // fstream.h included.
: ifstream fin;
: fin.open(filename);
: while(fin.good())
: {
: while((ios&) fin.get(ch))
: cout<<ch;
: }
: 有直接就讀進integer的方法嗎?謝謝~

int integer;

while(fin>>integer)
cout<<integer;

--
※ Origin: 程式設計樂園 ◆ From: 203.69.20.66

0 new messages