我目前正试图让这段代码正常工作:
//TODO THIS IS NOT WORKING
printf("WARNING: THE USER INPUT WILL OVERWRITE THE FILE \"%s\". ARE YOU SURE? [Y/N] ", output_file_name);
int c;
while(read(0, &c, 1) == 1) {
if (((unsigned char) c) == 'y')
printf("YES");
}
我希望代码能做什么: 我期待得到文本
警告:用户输入将覆盖文件" FILENAME"。你确定吗? [Y / N]
在命令行中打印。并且为了能够写一些内容,在按下输入后,我希望看到文本 是 打印的次数与给定的' y& #39;在之前的输入中。相反,这就是我得到的:
./myprogram.o
I type things.
Including yyyy
ydkfasjf
yay
Now I'm tired and will press ctrl+d to write EOF to stdin...
WARNING: THE USER INPUT WILL OVERWRITE THE FILE "FILENAME". ARE YOU SURE? [Y/N]YESYESYESYESYESYESYESYES
Matthias@BASH ~/folder/
这里发生了什么?我认为printf和read函数不知何故发生了碰撞......有人可以赐教我吗?
答案 0 :(得分:0)
Elements titles = doc.getElementsByTag("TITLE");
Elements descriptions = doc.getElementsByTag("DESCRIPTION");
Elements img = doc.getElementsByTag("IMAGE");
String Imgurl=img.get(0).text();
System.out.println(Imgurl);//EMPTY !!
通常是行缓冲。要在下一行代码之前强制输出,请将child=serializers.IntegerField(required=False)
添加到输出或使用public class reportAction {
private BindingContainer bindings;
private String createURL = "";
public String getCreateURL(){
bindings = getBindings();
AttributeBinding test = (AttributeBinding) bindings.get("DesformatName");
System.out.println(LOG + test);
return test.toString();
}
}
。
同时将stdout
更改为'\n'
,以便将数据正确读入fflush(stdout)
。
int c