[問題] c++讀檔入指標陣列
想要讀入一個檔案如下
n
tt
and
Ar
ar
.
.
.
想要把每行讀入一個指標陣列 又不想用gerline
目前的想法是
int main()
{
int i;
char *number=new char[1000];
ifstream instream;
instream.open("test.txt")
for(i=0;i<5;i++)
instream>>number;
cout<<number[1];
instream.close();
}
本來以為輸出會是tt 結果是t
對指標陣列還不太熟 懇請版友解惑 感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 134.208.33.70
※ 編輯: cophie 來自: 134.208.33.70 (03/15 20:15)
→
03/15 20:17, , 1F
03/15 20:17, 1F
→
03/15 20:18, , 2F
03/15 20:18, 2F
→
03/15 20:56, , 3F
03/15 20:56, 3F
推
12/28 23:26, , 4F
12/28 23:26, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章