小编Chu*_*cky的帖子

为什么我的网络浏览器上没有HTML渲染?

它只是在谷歌浏览器中显示如下:

<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1 align="center">Hello World!<br/>Welcome to My Web Server.</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

为什么不按预期转变?

编辑:是的文件确实有.html文件名.根据我正在使用的教程,我不确定它是否应该需要一个标题,它说它应该正确渲染而没有一个?所有这些都是新的,所以我不确定.

编辑:当我用textedit打开它时,我得到了这个:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.35">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
  </style>
</head>
<body>
<p class="p1">&lt;html&gt;</p>
<p class="p1">&lt;head&gt;</p>
<p class="p1">&lt;title&gt;Hello World!&lt;/title&gt;</p>
<p class="p1">&lt;/head&gt;</p>
<p class="p1">&lt;body&gt;</p>
<p class="p1">&lt;h1 align="center"&gt;Hello World!&lt;br/&gt;Welcome to My Web Server.&lt;/h1&gt;</p>
<p class="p1">&lt;/body&gt;</p>
<p …
Run Code Online (Sandbox Code Playgroud)

html rendering html-rendering

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

为什么这个真/假蕴涵功能在SML中不起作用?

val implies =
    fn x y = case x of false andalso case y of false => true
     | fn x y = case x of false andalso case y of true => true
     | fn x y = case x of true andalso case y of false => false
     | fn x y = case x of true andalso case y of true => true;  
Run Code Online (Sandbox Code Playgroud)

我无法编译.我对SML比较陌生,所以不太习惯一般的语言和语法.我做错了什么?

functional-programming sml high-level

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

具有一个goto标签的C代码无法按预期工作

我被要求打破一个C程序,这个程序最初只是一个主要的方法,有很多评论很好的段.如果发生错误,每个段都使用相同的定义函数字符串'die'.die函数使用goto标签'out'来关闭程序.

在将这些段中的每一个转换为函数之后,这些函数现在都是从底部的按比例缩小的main方法调用的,每个段的这个转出代码不再有效.'out'标签位于main中,XCode编译器告诉我goto标签尚未定义.

所以我想我问我如何以最有效的方式在每个本地函数中定义我的out标签?

以下是一些代码片段,所有代码片段都显示在它们的顺序/结构中:

模具定义

    #define die(msg, ...) do {                      \
(void) fprintf (stderr, msg, ## __VA_ARGS__); \
(void) fprintf (stderr, "\n");                \
goto out;                                     \
} while (0)
Run Code Online (Sandbox Code Playgroud)

使用die的函数示例

void createContext(void){
        context = clCreateContext (0, 1, &device_id, NULL, NULL, &err);
        if (!context || err != CL_SUCCESS)
            die ("Error: Failed to create a compute context!");
    }
Run Code Online (Sandbox Code Playgroud)

最后我的主要内容,其中包含最后的模具

main (int argc, char *argv[])
{

    (Several functions called here)

out:
    /* Shutdown and cleanup.  */
    if (data)
        free (data);

    if (results)
        free …
Run Code Online (Sandbox Code Playgroud)

c program-entry-point goto function

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

如何避免此SQL异常?

我有一个DBconnector类,我写过.这是使用它具有的插入查询方法的实例.暂时忽略查询:

ResultSet NewCustomer = db.executeInsert("SELECT s Bookings VALUES (surnameOut,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')");
Run Code Online (Sandbox Code Playgroud)

目前上面的行正在获得"未处理的异常类型SQLException"错误.它建议我用try/catch语句包围上面的内容,或者给出保持代码抛出异常的方法.我希望有一些方法可以在DBconnector类中对它进行排序,这样我就可以维护很小的单行来执行SQL查询.这可能吗?

以下是方法executeInsert方法的代码:

public ResultSet executeInsert(String query)throws SQLException {
        Statement s = null;
        ResultSet rs = null;
        try{
            s = con.createStatement();
            s.executeQuery(query);
            rs = s.getResultSet();
        }
        catch(SQLException e){}
        return rs;
    }
Run Code Online (Sandbox Code Playgroud)

java sql eclipse jdbc

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

使printf语句在openCL内核代码中工作

在下面的代码片段中,我试图printf()在代码中尝试打印出input[i]计算结果,以便我可以看到它正常工作.

但这并不像我希望的那样有效,因为引号printf()与内核的字符串格式相混淆,导致整个程序无法编译.我已经尝试使用转义字符\",它允许我输入内核的字符串但是在编译时给出了预期的表达式和缺少的字符错误.

有谁知道如何解决这个问题?这是检查内核代码结果的最佳方法吗?

    const char *KernelSource =         "\n"
"__kernel void relax(                    \n"
"   __global double* input,                \n"
"   __global double* output,               \n"
"   __global int N)             \n"
"{                                        \n"
"   int i = get_global_id(0);             \n"
"   if(i > 0 && i < N-1){                         \n"
"       input[i] = 0.25*input[i-1]+0.5*input[i]+0.25*input[i+1];  \n"
"       printf("input[%d] %f \n", i, input[i] )\n"
"   }                                        \n"
"}                                        \n"
"\n";
Run Code Online (Sandbox Code Playgroud)

c string kernel escaping opencl

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

有人可以解释这个OpenCL程序有什么问题吗?

我已经包含了主机程序的主要部分,我怀疑这里不正确:

http://pastebin.com/qVkv9E11

我的指针还不是很好,并且认为我可能错误地分配了一些变量.

这是内核程序,它应该让我知道我的程序正在尝试做什么:

    const char *KernelSource =           "\n"
"__kernel void sumElements(           \n"
"   __global float* input,            \n"
"   __global float output,            \n"
"   __global int N)                   \n"
"{                                    \n"
"   int i = get_global_id(0);         \n"
"   if(i < N)                         \n"
"       output += input[i];           \n"
"}                                    \n"
"\n";
Run Code Online (Sandbox Code Playgroud)

也许这会导致错误,因为我从未尝试过SIMT写入一个变量,如上所述.有可能做这样的事吗?我需要得到数组中所有元素的总和.

c multithreading kernel gpu opencl

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

这个结构被定义了,为什么函数认为它不是?

C++新手.只需制作一个简单的struct/array程序.为什么我不能像我打算在这里传递一系列结构?

int NumGrads();

int main()
{
      struct Student {
          int id;
          bool isGrad;
      }; 

    const size_t size = 2;
    Student s1, s2;
    Student students[size] = { { 123, true },
                             { 124, false } };

    NumGrads(students, size);

    std::cin.get();
    return 0;
}

int NumGrads(Student Stu[], size_t size){

}
Run Code Online (Sandbox Code Playgroud)

我明白,它必须是事做与参考值或值传递,但肯定如果我在main()定义了它,我不应该得到一个错误与NumGrads的参数?

c++ arrays parameters struct undefined

0
推荐指数
3
解决办法
139
查看次数