我有这个结构
typedef struct{
char **palavras;
}no;
我想基本上为这个字符串数组分配内存
而且我无法做到这一点,因为它表示它会在'之前预期一些事情('
no *atual;
atual->(*palavras)=calloc(1,sizeof(char*));
答案 0 :(得分:2)
您需要分几个阶段完成:
atual
,palavras
palavras
假设你需要分配10 palavras
,你可以这样做:
no *atual = malloc(sizeof(no));
atual->palavras = malloc(sizeof(char*)*10);
atual->palavras[0] = malloc(20);
...
答案 1 :(得分:-1)
您应该palavras
访问atual->palavras
,例如atual->palavras = calloc(5, sizeof(char *))
,char **
*atual->palavras
取消引用char *
。您也可以atual->palavras
为atual->palavras[0] = malloc(10 * sizeof(char))
指针分配内存,例如# To remove trailing slash
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]
# To remove .php extension
RewriteRule ^(.*)\.php$ $1 [R=301,L]
# To check whether the file exists then set it back internally
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L]
。