小编Cal*_*ray的帖子

正则表达式匹配数字,逗号和分号?

什么是正则表达式,它将匹配仅包含数字0到9,逗号和分号的字符串?我想在Java中使用它,如下所示:

word.matches("^[1-9,;]$") //Or something like that...
Run Code Online (Sandbox Code Playgroud)

我是正则表达式的新手.

java regex

24
推荐指数
4
解决办法
15万
查看次数

Bash'printf'等同于命令提示符?

我想在Windows的命令提示符中将一些String输入传递给一个小C程序.在bash我可以使用

$ printf "AAAAA\x86\x08\x04\xed" | ./program
Run Code Online (Sandbox Code Playgroud)

基本上,我需要一些东西来逃避命令提示符中的那些十六进制数字.

printf在命令提示符/ powershell中是否有等效或类似的命令?

谢谢

windows shell powershell command-line exploit

6
推荐指数
1
解决办法
8127
查看次数

单独线程中的多个表单

我正在尝试使用Windows窗体在C#中运行ATM模拟,该窗体可以有多个ATM机实例同时与银行账户进行交易.

我们的想法是使用信号量/锁定来阻止可能导致竞争条件的关键代码.

我的问题是:

如何在不同的线程上同时运行两个表单?特别是,所有这些如何适应Application.Run()已经存在的东西?

这是我的主要课程:

public class Bank
{
    private Account[] ac = new Account[3];
    private ATM atm;


    public Bank()
    {
        ac[0] = new Account(300, 1111, 111111);
        ac[1] = new Account(750, 2222, 222222);
        ac[2] = new Account(3000, 3333, 333333);


        Application.Run(new ATM(ac));


    }

    static void Main(string[] args)
    {
        new Bank();
    }
}
...that I want to run two of these forms on separate threads...

public partial class ATM : Form
{
    //local reference to the array of accounts
    private …
Run Code Online (Sandbox Code Playgroud)

.net c# multithreading winforms

3
推荐指数
1
解决办法
1万
查看次数

C++:Catch块没有捕获?

我有一个特定的Exception类,我想从类方法中抛出并从main()函数中调用它的调用代码.

但是,当我运行它时,我收到以下错误: Unhandled exception at 0x775915ee in OpenHashTable.exe: 0xC0000005: Access violation.好像它没有被处理.我不明白为什么会这样.这是涉及的代码:

main() {
    ......
        case 'i':   
        {
                cout << "Enter the positive integer you wish to insert: ";
                    //Input Validation.  
                if (!(cin >> number))
                {
                    cout << "Please enter a valid positive integer...\n\n";
                    cin.clear();
                    cin.ignore(numeric_limits<streamsize>::max(), '\n'); //Taken from http://stackoverflow.com/questions/2075898/good-input-validation-loop-using-cin-c
                    break;
                }
                try
                {
                    hashTable.add(abs(number)); //Add positive only integer
                }
                catch (FullTableException& fte)
                {
                    cout << "HashTable is full!" << endl;
                    break;
                }
                catch (DuplicateElementException& dee) //NOT BEING CAUGHT?
                { …
Run Code Online (Sandbox Code Playgroud)

c++ oop exception-handling exception try-catch

0
推荐指数
1
解决办法
1476
查看次数