问题:
用while 读取至换行字符(变量i指向换行字符),
for(j=0;j<i;j++)却会印出换行字符
char[80] i
char[0] char[1] Char[2] Char[3] Char[4]
L O V E '\n'
code: https://www.dropbox.com/s/rci9tepjqg8mbt1/inputReader.rar
http://ideone.com/7GyCfL
/**Start**/
InputStreamReader s1 = new InputStreamReader(System.in);
while ((ch[i] = (char) s1.read()) != 10) {i++;}
/*output*/
for (int j = 0; j < i; j++)
System.out.print(" \"" + ch[j] + "\"");
System.out.println("不会自动换行");
error:https://www.dropbox.com/s/ei4ad7tuzt6d4ox/inputreader.jpg
尝试:
1. Method:"while" check http://ideone.com/Ljzt1e
2. for(j=0;j0m< i-10m;j++) 结果正确,但不符合逻辑...
3. google InputStreamBuffer.read();用法
大大们感谢了!本鲁菜比巴... 练习都遇到一堆Bug