请教C/C++小# JobHunting - 待字闺中
q*0
1 楼
See the code below. I am confused that "len = 5" from main function, "len =
4" from RemoveDuplicate function. When does terminate '\0' count? Thanks.
#include
using namespace std;
void RemoveDuplicate(char str[])
{
int len = sizeof(str)/sizeof(str[0]);
cout << "len = " << len << endl;
}
int main()
{
char a[] = "abcd";
int len = sizeof(a)/sizeof(a[0]);
cout << "len = " << len << endl;
RemoveDuplicate(a);
return 0;
}
4" from RemoveDuplicate function. When does terminate '\0' count? Thanks.
#include
using namespace std;
void RemoveDuplicate(char str[])
{
int len = sizeof(str)/sizeof(str[0]);
cout << "len = " << len << endl;
}
int main()
{
char a[] = "abcd";
int len = sizeof(a)/sizeof(a[0]);
cout << "len = " << len << endl;
RemoveDuplicate(a);
return 0;
}