为了在 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?
我有字符串:" 12.3 I love paris 1990".
我想在删除第一个号后收到的字符串是: I love paris 1990
非常感谢.
我是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().
谁有人解释原因?
提前致谢.