可能重复:
C 编程语言中数组的大小?
我有一个 char 数组,我想在一个函数中处理它,我尝试了这样的代码:
int main(){
char *word = new char [5];
/*here we make this word
....
*/
process(word);
puts(word);
}
void process(char *word){
int sizeOfWord = sizeof(word)-1;
/* here is cycle that process the word, I need it lenght to know how long cycle must be
.....
*/
}
但我无法获得数组的长度sizeof
。为什么?我怎样才能得到它?