我想打印存储变量的位置.我谷歌它,我发现了这个:
int *p;
printf("memory location of ptr: %p\n", (void *)p);
Run Code Online (Sandbox Code Playgroud)
如果我写这个,是不是?
printf("memory location of ptr: %p\n", &p);
Run Code Online (Sandbox Code Playgroud)
我编译它,我没有得到任何错误或警告,但如果我把它们都放在程序中,这两个语句不会返回相同的值.
我将一个角色传递给我的程序,我想将这个角色存储到变量中.例如,我像这样运行我的程序./a.out s file.现在我想将argv [1](它的s)保存到变量中(假设我这样定义它char ch;.我看到了这种方法:
ch = argv[1][0];
Run Code Online (Sandbox Code Playgroud)
它的工作原理.但我无法理解.数组argv不是一维数组?如果我删除[0],我会收到警告warning: assignment makes integer from pointer without a cast
我用servlet和JSP构建了一个web应用程序,在我的Servlet中我计算了一周的数量:
private int findWeekNumber(String myDate)
throws ParseException{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date;
date = df.parse(myDate);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int week = cal.get(Calendar.WEEK_OF_YEAR);
System.out.println("week number is:" + week);
return week;
}
Run Code Online (Sandbox Code Playgroud)
然后我保存week到我的数据库.然后我week从我的数据库中检索.我怎样才能得到一周的开始 - 结束日期(周开始是星期一)week?让我们说weekNumber是30,我想计算20/07/2015 - 2015年7月26日.这里功能相同
我有一个类的两个构造函数Transactions,它们在最后一个参数中有所不同,其中第一个构造函数接受一个Label对象,第二个构造函数接受一个Box对象.
public class Transactions {
private String date;
private String kind;
private int employee;
private Label label;
private Box box;
public Transactions(String date, String kind, int employee, Box box) {
this.date = date;
this.kind = kind;
this.employee = employee;
this.box = box;
}
public Transactions(String date, String kind, int employee, Label label) {
this.date = date;
this.kind = kind;
this.employee = employee;
this.label = label;
}
...
}
Run Code Online (Sandbox Code Playgroud)
比方说,我创建类的对象Transactions是tr.我该如何区分它是哪一个?一个与Label …
我使用预准备语句来读取/写入我的数据库(SQLite)中的数据.在我的表中INVENTORY,有一些记录null在列中有值paleta(列VARCHAR在表中定义).我想选择这些记录,我试过:
sq = "SELECT * FROM INVENTORY WHERE paleta = ? AND product = ? AND lot = ?";
//...
stm = c.prepareStatement(sq);
stm.setNull(1, java.sql.Types.VARCHAR);
stm.setString(2, "theIdOftheProduct");
stm.setString(3, "theLotOftheProduct");
ResultSet rs = stm.executeQuery();
Run Code Online (Sandbox Code Playgroud)
上面的查询没有返回任何东西..我删除了paleta = ?,我得到了我想要的记录..如何SELECT * FROM INVENTORY WHERE paleta is null etc..使用查询参数定义查询?
我正在尝试IsSELECTED使用preparedStatements 从表中选择一条记录.我的表有3个字段(日期(DATETIME),早上(BOOL),中午(BOOL),夜晚(BOOL))和一个带有这些值的记录(2013-12-12,0,0,0).我的方法尝试选择具有给定日期的记录.
public void getTodayInfo(HttpSession session, String date)
throws ClassNotFoundException, SQLException{
System.out.println("flag1");
String sq = "SELECT date, morning, noon, night FROM IsSELECTED WHERE date='?'";
try {
System.out.println("flag2");
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection(path);
stm = c.prepareStatement(sq);
stm.setString(1, date);
System.out.println("flag3");
ResultSet rs = stm.executeQuery(sq);
while (rs.next()) {
System.out.println("flag4");
Shift s = new Shift(rs.getString(date), rs.getBoolean("morning"), rs.getBoolean("noon"), rs.getBoolean("night"));
System.out.println("flag5" + s.toString());
session.setAttribute("shiftsToday", s);
}
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (stm != null)
stm.close();
if (c != null)
c.close(); …Run Code Online (Sandbox Code Playgroud) 我有 2 个表TABLE1,TABLE2在 sqlite 数据库中。表2具有表1的一些记录。我想要的是从表 1 中选择所有记录,这些记录在表 2 中不存在。所以我编码:
String sq = "SELECT TABLE1.name, TABLE1.surname, TABLE1.id FROM TABLE1"
+ "LEFT JOIN TABLE1"
+ "ON TABLE1.id <> TABLE2.id";
Run Code Online (Sandbox Code Playgroud)
然而这个查询返回了一些我不明白的东西..哪个是正确的查询?
我有这个输入
<input id="look" type="number" min="0" step="0.01" max="100000" class="form-control" name="number" required>
Run Code Online (Sandbox Code Playgroud)
我想读取用户当时将放置的值.所以我写了
$(function() {
$('#look').on('keyup', function(e) {
var temp2 = $('look').val();
alert(temp2);
});
});
Run Code Online (Sandbox Code Playgroud)
当用户开始输入警报内的值时,未定义..
我有 2 张纸,我想将一个单元格的值显示到另一张纸上。我想在另一个工作表中显示的单元格是C26,它具有值€719.39,该工作表的名称是January. 在另一张纸的一个单元格中,我写
=INDIRECT('January'!C26)
Run Code Online (Sandbox Code Playgroud)
我有一个错误
Error Function INDIRECT parameter 1 value is '€719.39'. It is not a valid cell/range reference.
Run Code Online (Sandbox Code Playgroud)
为什么我收到这个错误?
我从一个有名称的文件夹中加载一些文件file 1.pdf,file 2.pdf我想将它们全部加载到我的程序中.如果我新增了它们的总数,我会这样做:
for(int i=1; i<=100; i++){
File pdfFile = new File("file "+i+".pdf");
//...
}
Run Code Online (Sandbox Code Playgroud)
但我不知道总数.如果没有其他文件,那么条件是什么,然后退出?
do{
File pdfFile = new File("file "+i+".pdf");
//...
}while(//there are files...)
Run Code Online (Sandbox Code Playgroud)