小编use*_*738的帖子

Javascript - 在隐藏字段中存储对象数组

我需要在隐藏字段中存储一些输入,所以当我打印后请求时,我得到:

Array ( [0]=>1 [1]=>2 [2]=>3 )
Run Code Online (Sandbox Code Playgroud)

我已经尝试过:

var elems = [];
elems.push['1'];
elems.push['2'];
elems.push['3'];

$('#input_hidden_field').val(elems);
Run Code Online (Sandbox Code Playgroud)

但它不起作用,任何人都可以帮助我吗?

arrays jquery post serialization object

27
推荐指数
3
解决办法
8万
查看次数

在OS X 10.8上有一些关于GlKit的好例子吗?

我正在尝试使用GLKitfor 创建一个简单的应用程序OSX 10.8,但找不到任何示例.苹果文档刚刚从复制iOSMac没有真正的例子.我有一个3.2 profile设置的上下文,一个CVDisplayLink绘图,但没有.我正试图从iOS(也用GlKit)制作一些简单的绘图.任何帮助,将不胜感激.谢谢.

macos opengl-3 glkit osx-mountain-lion

12
推荐指数
0
解决办法
864
查看次数

PHP - imagettftext无法正常工作并安装了GD

我正在寻找这个问题的答案是很长时间.我找到的所有解决方案都是捕捉字体名称,但我很确定这不是我的问题.

它看起来像是安装了GD

array(11) {
  ["GD Version"]=>
  string(27) "bundled (**2.0.34 compatible**)"
  ["FreeType Support"]=>
  bool(false)
  ["T1Lib Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(true)
  ["JPEG Support"]=>
  bool(true)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XPM Support"]=>
  bool(true)
  ["XBM Support"]=>
  bool(true)
  ["JIS-mapped Japanese Font Support"]=>
  bool(false)
}
Run Code Online (Sandbox Code Playgroud)

上面你可以看到我的GD支持.我的PHP版本是5.3,我在Linux上运行.

我尝试过来自不同网站的几个不同的代码示例,但都没有.ImageString确实适合我,但我需要让imagettftext工作..

这是我现在尝试的最后一个代码 -

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400, 100) or die("Can't create image!");

// Create some colors
$white = imagecolorallocate($im, …
Run Code Online (Sandbox Code Playgroud)

php gd image imagettftext

7
推荐指数
4
解决办法
3万
查看次数

使用node-jspdf的jsPDF服务器端(node.js)用法

我实际上试图在服务器端包含jspdf,然后将其用于简单的pdf生成(简单的文本"Hello world!")(转到url-获取pdf localhost:8080).现在我面临的第一个问题是

  • 如何包含它/如何在节点中使用jsPDF?
  • 在尝试使用npm install node-jspdf它时,它会给出以下错误 -

> G:\test\myproj>npm install node-jspdf
 node-jspdf@0.0.3 install G:\test\myproj\node_modules\node-jspdf
 sh install.sh
Run Code Online (Sandbox Code Playgroud)
'sh' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs
\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-jspdf"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1
npm ERR! code ELIFECYCLE

npm ERR! node-jspdf@0.0.3 install: `sh install.sh`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-jspdf@0.0.3 install …
Run Code Online (Sandbox Code Playgroud)

javascript node.js jspdf

6
推荐指数
2
解决办法
9368
查看次数

使用指针遍历char数组

我是C语言的新手,想知道如何使用指针获取数组的每个元素。当且仅当您知道数组的大小时,这才容易。因此,让代码为:

#include <stdio.h>

int main (int argc, string argv[]) {
    char * text = "John Does Nothing";
    char text2[] = "John Does Nothing";

    int s_text = sizeof(text); // returns size of pointer. 8 in 64-bit machine
    int s_text2 = sizeof(text2); //returns 18. the seeked size.

    printf("first string: %s, size: %d\n second string: %s, size: %d\n", text, s_text, text2, s_text2);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在我要确定的大小text。为此,我发现字符串将以'\0'字符结尾。所以我写了以下函数:

int main (int argc, string argv[]) {
    char * text = "John Does …
Run Code Online (Sandbox Code Playgroud)

c arrays string pointers sizeof

6
推荐指数
1
解决办法
3万
查看次数

悬空指针和内存泄漏有什么区别?

我是C++的新手,想问下面的代码是否是悬空指针或内存泄漏的一个例子,因为它指向动态分配的数组:

int * n = new int[10];
for (int prev = 0; prev < 10; prev++) {
    *n = *(n + prev + 1);
}
delete[] n;
n = nullptr;
Run Code Online (Sandbox Code Playgroud)

memory-leaks dynamic-allocation c++11 dangling-pointer

5
推荐指数
3
解决办法
1027
查看次数

为什么C/C++编译器并不总是使++成为原子?

作为标题,当我们写入++aC/C++,似乎编译器可以将其编译为:

inc dword ptr[i]
Run Code Online (Sandbox Code Playgroud)

这是原子的,或者:

mov eax,  dword ptr[i]
inc eax
mov dword ptr[i], eax
Run Code Online (Sandbox Code Playgroud)

这不是原子的.

将它编译为非原子样式有什么好处吗?

c c++ compiler-construction atomic

5
推荐指数
2
解决办法
215
查看次数

char类型按位操作失败到int

我尝试在C中按位操作.这是我的代码:

int main() {
    char c = 127;
    c <<= 1;
    if (c == 0xfe) {
        printf("yes");
    }
    else {
        printf("No");
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

系统控制台打印否.我希望收到的是是.位移后c中的值为ffffffffe.似乎系统已经将8位改为32位.谁能帮我.

c bit-manipulation type-conversion integer-promotion type-promotion

4
推荐指数
1
解决办法
63
查看次数

在C中复制strtok令牌的内容

需要分离一个字符串然后再进行另一次分离.

char *token = strtok(str, ",");
while(token){
    char *current_string = malloc(sizeof(char) * strlen(token));
    strcpy(current_string, token);

    char *tk = strtok(current_string, ":"); // KEY
    printf("key: %s ", tk);
    tk = strtok(0, ":");                    // VALUE
    printf("value: %s\r\n", tk);
    printf("%s\n", token);
    token = strtok(0, ",");
}

printf("Done\n");
Run Code Online (Sandbox Code Playgroud)

试图复制内容token,但这样做会混淆token变量中的内容.它只处理一行而不是它应该处理的三行.我怀疑问题是strcpy(current_string, token)但不确定我应该怎么做.

c delimiter strtok

4
推荐指数
1
解决办法
421
查看次数

使用 memcpy 复制二维数组

我想使用 memcpy 但它通常定义为指针。我们可以用这个函数为数组分配一个新的内存吗?

例如,我们有一个matrix1[13][15],我们想将它分配给matrix2[13][15]这两个数组是独立的。

c

3
推荐指数
1
解决办法
8131
查看次数