我使用以下命令加载c文件程序,只需点击一下即可在终端的GDB中运行:
public class Gambler {
public static void main(String[] args)
{
String a, b;
int dotNumber;
String finalOut;
String dots = "";
Scanner userInput = new Scanner(System.in);
System.out.println ("please input a word");
a = userInput.next();
System.out.println ("please input another word");
b = userInput.next();
if (a.length() + b.length() < 30) {
dotNumber = 30 - a.length() + b.length();
for (int i = 1; i <= dotNumber; i++); {
dots = dots + ".";
}
}
finalOut = a + dots + b;
System.out.print(finalOut);
}
}
我想在加载程序后几秒钟睡觉,但在GDB中启动程序之前,有些事情如下:
gdb --eval-command='file c.out' --eval-command='c'
答案 0 :(得分:2)
给gdb一个让它暂停5秒的命令行选项的方法是告诉它运行&#34; sleep 5&#34; shell中的命令:
--eval-command="shell sleep 5"