小编use*_*430的帖子

c 正则表达式代码不起作用?

我在下面有这段代码,用于检查用户是否输入了语法正确的 url。正则表达式代码是从C 中的正则表达式获得的:示例?

printf("Enter the website URL:\n");
fgets(str, 100, stdin);
if (!strcmp(str, "\n")) {
    printf("Empty URL ");
    exit(2);
}

regex_t regex;
int reti;
char msgbuf[100];

/* Compile regular expression */
reti = regcomp(&regex, "[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)?$", 0);
if (reti) {
    fprintf(stderr, "Could not compile regex\n");
    exit(3);
}

/* Execute regular expression */
reti = regexec(&regex, str, 0, NULL, 0);
if (!reti) {
    puts("Match");
} else if (reti == REG_NOMATCH) {      //This else if always executes.
    puts("No match");
    exit(4);
} else { …
Run Code Online (Sandbox Code Playgroud)

c regex url

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

Qt GUI应用程序意外结束

嗨,我正在Linux上工作,我正在尝试创建一个GUI应用程序,以配合我已经制作的可执行文件.

出于某种原因,它意外地结束了.没有错误消息,它只是在Qt控制台窗口中说它意外地以退出代码0结束.

有人可以帮我看一下.我在Linux上工作.

我也会在这里粘贴代码.

void MainWindow::on_pushButton_clicked()
{
    QString stringURL = ui->lineEdit->text();

    ui->labelError->clear();
    if(stringURL.isEmpty() || stringURL.isNull()) {
        ui->labelError->setText("You have not entered a URL.");
        stringURL.clear();
        return;
    }

    std::string cppString = stringURL.toStdString();
    const char* cString = cppString.c_str();

    char* output;

    //These arrays will hold the file id of each end of two pipes
    int fidOut[2];
    int fidIn[2];

    //Create two uni-directional pipes
    int p1 = pipe(fidOut);                //populates the array fidOut with read/write fid
    int p2 = pipe(fidIn);                 //populates the array fidIn  with read/write fid
    if …
Run Code Online (Sandbox Code Playgroud)

c c++ qt pipe

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

OpenCV让用户选择打开图像

我试图在opencv中创建一个简单的图像处理器.到目前为止,我已尝试使用此代码从文件中打开设置图像.

#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    Mat im = imread("c:/image.jpg");
    if (im.empty()) 
    {
        cout << "Cannot load image!" << endl;
        return -1;
    }
    imshow("Image", im);
    waitKey(0);
}
Run Code Online (Sandbox Code Playgroud)

由于这只允许打开设置的图像文件,我如何修改它以便用户选择图像?

这是可能的还是我只能从文件中加载一组图像?

谢谢.

c++ opencv

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

将日期格式化为特定格式

将字符串日期格式化为特定格式的最佳方法是什么?

例如,如果输入30/09/2014它将被格式化为2014-09-30前者的任何其他类似的日期格式?

.net c# datetime

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

c#搜索arraylist

我正在制作一个从文件中读取数据的简单应用程序.到目前为止,我已经能够将所有数据读入arraylist.

但是,我需要让用户能够搜索arraylist并返回与其搜索相关的所有值.要搜索用户,请在文本框中输入关键字或内容,当他们单击搜索时,相关结果将显示在列表框中.

我需要什么代码才能搜索arraylist.

c# search arraylist

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

$ _SESSION等于数据库中的值?

当一个人登录我的网站时,我需要检查数据库中的roleid值,并依赖于我需要允许/拒绝访问页面.

我有这个代码,但它说$ _SESION变量'Access'是未定义的,我不明白为什么?

            $email = mysql_real_escape_string($_POST['email']);
            $password = md5(mysql_real_escape_string($_POST['password']));

            $checklogin = mysql_query("SELECT * FROM person WHERE email = '" . $email . "' AND password2 = '" . $password . "'");

            if (mysql_num_rows($checklogin) == 1) {
                $row = mysql_fetch_array($checklogin);
                $roleid = $row['roleid'];

                $_SESSION['Email'] = $email;
                $_SESSION['LoggedIn'] = 1;
                $_SESSION['Access'] = $roleid;

                echo "<h1>Success</h1>";
                echo "<p>We are now redirecting you to the member area.</p>";
                echo "<meta http-equiv='refresh' content='2;index.php' />";
            } 

            else {
                echo "<h1>Error</h1>";
                echo "<p>Sorry, your account could not be …
Run Code Online (Sandbox Code Playgroud)

php session-variables

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

解决在java中输出的变量的内存

下面的代码用于根据所选日期使用可用时间填充组合框.

但是由于某种原因,组合框正在存储数据示例的内存地址:

Restaurant.Time@1a28362
Restaurant.Time@5fcf29
...
Run Code Online (Sandbox Code Playgroud)

我知道它得到了正确的时间.但是,我如何实际打印出实际物品?

TimeList times = dbConnector.selectTimes(lblDay.getText());//lblDay stores the date from the jCalendar button
cmbNewResTimes.removeAllItems();
for (int pos1 = 0; pos1 < times.size(); pos1++) {
    cmbNewResTimes.addItem(times.getTimeAt(pos1).toString());
}
Run Code Online (Sandbox Code Playgroud)

java swing combobox jcombobox

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

替换逗号和空格c#

如何替换字符串中的逗号和空格-我试过这个:

FeatureIds = Regex.Replace(config.FeaturePacks, @"[, ]", "-"),

但它正在用2代替它-:

F0--F1--F2

输入字符串是这样的:

F0,F1,F2

c# regex string replace

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

插入数据库java时出现空指针异常

嗨,我有下面的方法,应该将值插入我的数据库.但是我在PreparedStatement行上获得了Null Pointer Exception

   public void insertReservation(String name, String phone, int size, String date, String time, String additionalRequirements, String memberID, String themeID) throws SQLException, ClassNotFoundException {

        try {
            String strQuery = "INSERT INTO reservation VALUES (?, ? ,?, TO_DATE(?, 'dd-MMM-yy'), ?, ?, ?, ?)";
            PreparedStatement stmt = conn.prepareStatement(strQuery);/
            stmt.setString(1, name);
            stmt.setString(2, phone);
            stmt.setInt(3, size);
            stmt.setString(4, date);
            stmt.setString(5, time);
            stmt.setString(6, additionalRequirements);
            stmt.setString(7, memberID);
            stmt.setString(8, themeID);
            results = stmt.executeQuery();

        } catch (Exception e) {
            e.printStackTrace();
        }//end try
    }
Run Code Online (Sandbox Code Playgroud)

我是否正确地将其插入我的数据库?我不知道为什么我得到这个空指针exeception错误.

java sql nullpointerexception

-2
推荐指数
1
解决办法
1717
查看次数