它只是在谷歌浏览器中显示如下:
<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"><html></p>
<p class="p1"><head></p>
<p class="p1"><title>Hello World!</title></p>
<p class="p1"></head></p>
<p class="p1"><body></p>
<p class="p1"><h1 align="center">Hello World!<br/>Welcome to My Web Server.</h1></p>
<p class="p1"></body></p>
<p …Run Code Online (Sandbox Code Playgroud) 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比较陌生,所以不太习惯一般的语言和语法.我做错了什么?
我被要求打破一个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) 我有一个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) 在下面的代码片段中,我试图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) 我已经包含了主机程序的主要部分,我怀疑这里不正确:
我的指针还不是很好,并且认为我可能错误地分配了一些变量.
这是内核程序,它应该让我知道我的程序正在尝试做什么:
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++新手.只需制作一个简单的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的参数?