var CurrentDate = new Date();
function addDays(dateObj, numDays) {
dateObj.setFullYear(2018, 0, 15 + numDays);
return dateObj;
}
if (CurrentDate <= addDays(new Date(), 112)){
document.getElementById('t1').innerHTML = "We are on the first quarter";
} else if (CurrentDate <= addDays(new Date(), 224)) {
document.getElementById('t2').innerHTML = "We are on the second quarter";
} else if (CurrentDate <= addDays(new Date(), 336)) {
document.getElementById('t3').innerHTML = "We are on the third quarter";
}
// start and end date
var
startDate = addDays(new Date(), 119),
endDate = addDays(new Date(), 224);
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
// date array
var getDateArray = function(start, end) {
var
arr = new Array(),
dt = new Date(start);
while (dt <= end) {
arr.push(new Date(dt).toLocaleDateString("es-ES", options));
dt.setDate(dt.getDate() + 1);
}
return arr;
}
var test = document.getElementById('l1');
var data = getDateArray(startDate, endDate);
var dataSlice = data.length,
chunk = 7,
ulelement;
var ulelement = document.createElement("ul");
for (var i = 0; i < dataSlice; i+= chunk)
{
ulelement.innerHTML += '<li>' + data.slice( i, i+chunk) + '</li>';
}
test.appendChild(ulelement);
我正在使用clang和-fsanitize =地址抱怨内存访问溢出变量并终止我的程序,但是当我单步执行gdb时,我可以看到是的,所有内容都已定义,它应该打印两个地址,然后是'a ”。
如果我删除中间的“* p2”它运行正常,即打印一个指向半指针的指针,导致我出现问题。
答案 0 :(得分:5)
std::cout
假设所有char*
指向空终止的字符串。如果您想要地址,请将其投放到void*
。