我正在尝试使用返回类型作为boolean创建一个函数...程序的语法似乎是正确的但编译器给出错误....
我包含的头文件是:
#include<stdio.h>
#include<stdlib.h>
Run Code Online (Sandbox Code Playgroud)
我创建的功能是:
34.bool checknull(struct node* node){
35. if ( node != NULL )
36. return TRUE;
37.
38. return false;
39.}
Run Code Online (Sandbox Code Playgroud)
我在编译时得到的是
bininsertion.c:34:1: error: unknown type name ‘bool’
bininsertion.c: In function ‘checknull’:
bininsertion.c:36:10: error: ‘TRUE’ undeclared (first use in this function)
bininsertion.c:36:10: note: each undeclared identifier is reported only once for each function it appears in
bininsertion.c:38:9: error: ‘false’ undeclared (first use in this function)
Run Code Online (Sandbox Code Playgroud)
我用小写和大写字母都试过"真,假",但似乎没有用......
button.setBackgroundResource(R.Drawable.abc);
if ( button.getBackground()==getResources().getDrawable(R.drawable.abc))
{
button.setBackgroundResource(R.drawable.xyz);
}
else if( button.getBackground()==getResources().getDrawable(R.drawable.xyz) )
{
button.setBackgroundResource(R.drawable.abc);
}
Run Code Online (Sandbox Code Playgroud)
我想比较按钮上设置的背景图像.上面的代码取自Stack Overflow ...但它似乎不起作用
请建议一个更好的方法.
我想逐个输入数组中的16个字符......
#include<stdio.h>
void main(){
int i,j;
char a[4][4];
printf("Enter Values in array : ");
for ( i=0 ; i<=3 ; i++ )
{
for ( j=0 ; j<=3 ; j++ )
{
printf("a[%d][%d] : ",i,j);
scanf("%c",&a[i][j]);
}}
for ( i=0 ; i<=3 ; i++ )
{
for ( j=0 ; j<=3 ; j++ )
{
printf("a[%d][%d] : %c\n",i,j,a[i][j]);
}}}
Run Code Online (Sandbox Code Playgroud)
而输出是
a[0][0] : q
a[0][1] : a[0][2] : w
a[0][3] : a[1][0] : e
a[1][1] : a[1][2] : r
a[1][3] : …Run Code Online (Sandbox Code Playgroud) 这是我的servlet的代码......
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
private String message;
public void init(){
message="Hello World";
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>"+message+"</h1>");
}
public void destroy(){
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用xampp的tomcat 7
这是我的web.xml文件
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)
我的web.xml位于%TOMCAT_HOME%/ webapps/ROOT/WEB_INF目录中,而我的HelloWorld.class位于%TOMCAT_HOME%/ webapps/ROOT/WEB_INF/classes目录中.
当我尝试从浏览器运行我的文件时,我输入
http://localhost:8080/HelloWorld
在地址栏中显示以下Servlet异常
type Exception report
message
description The server encountered an internal error () that …Run Code Online (Sandbox Code Playgroud)