while当我使用时,我似乎遇到了循环问题set -e:
1 #!/bin/bash
2 # This is a script to perform initial configurations of CentOS 7.2
3 # Written by Robert J.
4
5 # Exit if unexpected condition
6 set -e;
7
8 # Simple die function
9 dieaquickdeath(){
10 code=$1;
11 message=$2;
12 printf "$message\n";
13 exit "$code";
14 }
15
16 #
17 ## There is an initial prompt here that was removed for simplification.
18 #
19 InputPassword1=1
20 InputPassword2=2
21 …Run Code Online (Sandbox Code Playgroud) 我似乎遇到了一个奇怪的情况,我不会在C++中.当我执行一个解析和替换字符串的函数(罗马数字).如果字符串不存在,我最终会超出界限:
Mac Shell: CPP/>$ ./Roman2Num
Retrieving input:
------------------
Enter a number: 24
input: XXIV
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string
Abort trap: 6
Mac Shell: CPP/>$ ./Roman2Num
Retrieving input:
------------------
Enter a number: 29
input: XXVIV
Roman: XXIX
Mac Shell: CPP/>$ ./Roman2Num
Retrieving input:
------------------
Enter a number: 1999
input: MDCDLXLVIV
Roman: MDCDLXLIX
Mac Shell: CPP/>$ ./Roman2Num
Retrieving input:
------------------
Enter a number: 1998
input: MDCDLXLVIII
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: basic_string
Abort …Run Code Online (Sandbox Code Playgroud)