为什么我们在strok()函数中使用null ?
while(h!=NULL)
{
h=strtok(NULL,delim);
if(hold!=NULL)
printf("%s",hold);
}
Run Code Online (Sandbox Code Playgroud)
当*h指向字符串时,该程序会执行什么操作?
这是使用链接列表的Stack实现的完整代码.这是来自詹姆斯·阿斯普内斯耶鲁大学的数据结构笔记(它有什么用?)
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
struct elt {
struct elt *next;
int value;
};
/*
* We could make a struct for this,
* but it would have only one component,
* so this is quicker.
*/
typedef struct elt *Stack;
#define STACK_EMPTY (0)
/* push a new value onto top of stack */
void
stackPush(Stack *s, int value)
{
struct elt *e;
e = malloc(sizeof(struct elt));
assert(e);
e->value = value;
e->next = *s;
*s = e;
} …Run Code Online (Sandbox Code Playgroud)