如何计算在以下程序中传递给函数的参数的数量:
#include<stdio.h>
#include<stdarg.h>
void varfun(int i, ...);
int main(){
varfun(1, 2, 3, 4, 5, 6);
return 0;
}
void varfun(int n_args, ...){
va_list ap;
int i, t;
va_start(ap, n_args);
for(i=0;t = va_arg(ap, int);i++){
printf("%d", t);
}
va_end(ap);
}
Run Code Online (Sandbox Code Playgroud)
这个程序在ubuntu 10.04下通过我的gcc编译器输出:
234561345138032514932134513792
Run Code Online (Sandbox Code Playgroud)
那么如何找到多少没有.实际传递给函数的参数?
嘿,我想知道创建富文本编辑器背后的概念是什么.我的意思是如何创建一个富文本编辑器.我想学习实施.
PS:请不要建议使用YUI或任何其他内置库.我想自己做一个.
那背后的概念是什么?
谢谢 :)
我正在学习Java中的GUI,为此我创建了一个演示程序:
import java.awt.*;
public class FrameDemo extends Frame {
public FrameDemo(){
super("Frame Demo");
setSize(200, 200);
setVisible(true);
}
public static void main(String args[]){
new FrameDemo();
}
}
Run Code Online (Sandbox Code Playgroud)
它编译成功.但是当我尝试执行该程序时,我发现以下错误:
Exception in thread "main" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
at java.awt.Window.<init>(Window.java:437)
at java.awt.Frame.<init>(Frame.java:419)
at FrameDemo.<init>(FrameDemo.java:4)
at FrameDemo.main(FrameDemo.java:9)
Run Code Online (Sandbox Code Playgroud)
我正在使用Xubuntu 10.10并java -version给出:
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1)
OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
还有一件事:当我尝试执行Dr. Java和HJSplit的jar文件时,我遇到了同样的错误.
我是servlet开发的新手,我正在阅读电子书,发现我可以使用重定向到不同的网页
setHeader("Location", "http://www.google.com")
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为我已将此代码编写为:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ModHelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException{
// response.addHeader("Location", "http://www.google.com");
response.setHeader("Location", "http://www.google.com");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html><head><title>Modified Hello World</title></head><body>");
pw.println("<h1>");
//getInitParameter function reads the contents ot init-param elements.
pw.println(getInitParameter("message"));
pw.println("</h1>");
pw.println("</body></html>");
pw.close();
}
}
Run Code Online (Sandbox Code Playgroud)
我已经使用我的程序检查了标题以获取网页的标题,如下所示:
import java.net.*;
import java.io.*;
class getHeaders{
public static void main(String args[]){
URL url = null;
URLConnection urc = null;
try {
url = new URL(args[0]);
urc = url.openConnection(); …Run Code Online (Sandbox Code Playgroud) 构造函数中缓冲区大小的含义是什么?
BufferedReader(Reader in, int size)
Run Code Online (Sandbox Code Playgroud)
正如我写的程序:
import java.io.*;
class bufferedReaderEx{
public static void main(String args[]){
InputStreamReader isr = null;
BufferedReader br = null;
try{
isr = new InputStreamReader(System.in);
// System.out.println("Write data: ");
// int i = isr.read();
// System.out.println("Data read is: " + i);
//Thus the InputStreamReader is useful for reading the character from the stream
System.out.println("Enter the data to be read by the bufferedReader: ");
//here isr is containing the lnefeed already so this is needed to be flushed. …Run Code Online (Sandbox Code Playgroud) 我在访问谷歌驱动器选择器时遇到以下错误,但是选择器正确显示没有任何错误.
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://docs.google.com') does not match the recipient window's origin ('http://localhost').
Invalid 'X-Frame-Options' header encountered when loading 'https://docs.google.com/picker?protocol=gadgets&origin=http%3A%2F%2Flocalho…%3Atrue%7D))&rpctoken=e2x1eop3h1rr&rpcService=2qeo0ns6gu13&thirdParty=true': 'ALLOW-FROM http://localhost' is not a recognized directive. The header will be ignored.
Run Code Online (Sandbox Code Playgroud)
PSB我的开发者控制台的截图
此外,我已经提到这个问题谷歌驱动器选择器 - 开发人员密钥无效错误,但我认为谷歌api有一些变化,所以这件事不起作用.
代码段 -
var picker = new google.picker.PickerBuilder()
.setLocale(lkGoogleSettings.locale)
.setOAuthToken(accessToken)
.setCallback(pickerResponse)
.setOrigin(lkGoogleSettings.origin);
Run Code Online (Sandbox Code Playgroud)
谢谢
作为一项任务,我必须在局域网上找到所有活着的计算机.我正在使用类的isReachable功能InetAddress.但问题是没有任何东西可以显示给我.所以我试图isReachable使用谷歌的IP,但仍然无法访问.
这是代码:
import java.net.*;
public class alive{
public static void main(String args[]){
try{
InetAddress ia = InetAddress.getByAddress(new byte[]{(byte)209, (byte)85, (byte)153, (byte)104});
boolean b = ia.isReachable(10000);
if(b){
System.out.println("Reachable");
}
else{
System.out.println("Unrachable");
}
}catch(Exception e){
System.out.println("Exception: " + e.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出是: Unreachable
一些比赛考试中的问题:
The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP addressed could belong to this network?
1: 172.57.88.62 & 172.56.87.23
2: 10.35.28.2 & 10.35.29.4
3: 191.203.31.87 & 192.234.31.88
4: 128.8.129.43 & 128.8.161.55
Run Code Online (Sandbox Code Playgroud)
现在我对这个问题感到困惑,我已经读过一个子网掩码是模式的:
1111 1111. 1111 1111. 1111 1
我的意思是从左侧开始1但是在这个子网掩码中:
1111 1111. 1111 1111. 0001 1111. 0000 0000
Run Code Online (Sandbox Code Playgroud)
那么背后的实际原则是什么呢?请解释.我完全糊涂了.
提前致谢 :)
我只是在网上冲浪,发现了一个类似的查询:
sql = "select milk_rate from special_milk_rate
where code_producer_id=? and effective_from <= ?
and effective_till >= ?"
Run Code Online (Sandbox Code Playgroud)
这个查询究竟意味着什么意味着什么是使用?在这个声明中.
还有一件事是在sql中使用&.
我是Sharepoint 2007的新用户,我已经做了一些google来找到一个列表的guid,我想用它来使用stssync进行我的sharepoint项目的Outlook同步.
有人可以帮我找出sharepoint 2007中的列表.
提前致谢.