什么是等同于C的fgets函数的Chapel代码?
`fgets(buffer, sizeof(buffer), stdin)`上面对fgets的调用从标准输入读取数据,直到遇到换行符。当遇到空格时,Chapel readln函数将停止读取。我希望readln一直读取,直到遇到换行符。有一个似乎是解决方案的iostringformat.toend,但是我如何让stdin的行为就像启用了它一样?
发布于 2019-02-13 00:30:21
使用readline而不是readln。请参阅https://chapel-lang.org/docs/modules/standard/IO.html#IO.channel.readline
例如,尝试此程序:
config const fname = "test.txt";
var r = openreader(fname);
var line:string;
while r.readline(line) {
write("I just read: ", line);
}https://stackoverflow.com/questions/54654029
复制相似问题