【发布时间】:2016-01-22 09:09:21
【问题描述】:
我需要向数组中添加一个字符串,并且需要一些帮助来弄清楚这意味着什么。这是我所拥有的:
#include <stdio.h>
#include <stdlib.h>
int insert(char *word, char *Table[], int n)
{
//*word is the string to be added, *Table[] is the array, n is
//the return value, which is the number of words in the array after adding *word
int i = 0;
while(*Table[i])
{
if strcmp(*Table[i], *word) == 0)
{
return n;
break;
}
}
}
我前段时间写了这篇文章,现在正在重新审视它。我不知道 while *Table[i] 是什么意思,因此我不知道后面的代码是什么意思。另外,这段代码不完整,所以不要告诉我它不会添加字符串。
【问题讨论】:
标签: c arrays string while-loop