小编bha*_*waj的帖子

如何在 Express.js 中传递 URL 中的字符串列表

为了在 URL 中传递单个参数,我在 Postman 中使用以下命令:

http://localhost:3000/api/prices/:shopId

这样可行!

现在,我想做的是将 shopId 替换为ShopIds 列表

我对如何实现这一点有什么想法吗?


伪代码:

URL for shopId = 1: http://localhost:3000/api/prices/1

URL for shopId = 2: http://localhost:3000/api/prices/2

我应该怎么做才能在单个 API 响应中同时获取 shopId 1 和 2?

node.js express postman

5
推荐指数
1
解决办法
7241
查看次数

从字符串Jquery中删除第一个数字

我有字符串:" 12.3 I love paris 1990".

我想在删除第一个号后收到的字符串是: I love paris 1990

非常感谢.

regex jquery

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

在C中使用malloc

我是C的初学者.我在想,这是怎么回事malloc.这是一个示例代码,我在试图理解它的工作时写了.

码:

#include<stdio.h>
#include<stdlib.h>
int main() {
  int i;
  int *array = malloc(sizeof *array);
  for (i = 0; i < 5; i++) {
    array[i] = i+1;
  }
  printf("\nArray is: \n");
  for (i = 0; i < 5; i++) {
    printf("%d ", array[i]);
  }
  free(array);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

OUTPUT:

Array is: 
1 2 3 4 5
Run Code Online (Sandbox Code Playgroud)

在上面的程序中,我只为1个元素分配了空间,但是数组现在包含5个元素.因此,当程序顺利运行而没有任何错误时,目的是什么realloc().

谁有人解释原因?

提前致谢.

c malloc realloc

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

标签 统计

c ×1

express ×1

jquery ×1

malloc ×1

node.js ×1

postman ×1

realloc ×1

regex ×1