c/c++字符串传递

#include <iostream>
#include <list>
using namespace std;

void  get_size(char str[100])
{
        cout<<"size in get_size   "<<sizeof(str)<<endl;
    
}




int main()
{
        char str[] = "hello";
        cout<<"size in main    "<<sizeof(str)<<endl;
        get_size(str); 
        return 0;
}

输出:

size in main    6
size in get_size   4


------------------
(program exited with code: 0)
Press return to continue

原因:函数传递字符串为指针传递

posted @ 2015-06-04 15:57  道心不可练  阅读(773)  评论(0编辑  收藏  举报