我正在编写一个简单的程序,以确保我完全理解当我通过哈佛CS50时,C中的指针是如何工作的.这是代码:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int *a = malloc(sizeof(int));
*a = 5;
printf("the address of pointer a is: %p\n", &a);
printf("the address that a is pointing to is: %p\n", a);
printf("the contents of a are: %i\n", *a);
printf("please enter a new value for a: \n");
scanf("%i", a);
printf("the address of pointer a is: %p\n", &a);
printf("the address that a is pointing to is: %p\n", a);
printf("the contents of a are: %i\n", *a);
int *b = malloc(sizeof(int));
*b …Run Code Online (Sandbox Code Playgroud) 这是我正在谈论的示例:https : //developer.apple.com/documentation/foundation/nsmutableorderedset/1410287-insert
插入功能显示为 insert(_:at:)
实际使用时,insert函数看起来更像:
namesArray.insert("John", at: 3)
:此后没有了"John"(尽管我想可能是"John":String–它的用途是什么?),而,实际需要去的那部分没有在文档的函数签名中提及。我实际上应该在使用逗号时知道/假设它在吗?所有Swift函数都是这种情况吗?
请注意,这不是有关下划线的问题,_-我知道为什么要使用下划线以及其用途。我是专门询问在函数签名中包含:和不包含的原因,。