读书人

帮小弟我看看哪里不对

发布时间: 2012-02-19 19:43:37 作者: rapoo

帮我看看哪里不对?
void test2()
{
 char string[10], str1[10];
 int i;
 for(i=0; i<10; i++)
 {
  str1[i] = 'a';
 }
 strcpy( string, str1 );
}
运行可以,为什么?

[解决办法]

C/C++ code
// test1.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"void test2() ;int _tmain(int argc, _TCHAR* argv[]){    test2() ;    return 0;}void test2() {     char string[10], str1[10];    int i;    memset(str1,0, 10) ;    for(i=0; i <9; i++)    {        str1[i] = 'a';    }    strcpy( string, str1 );    std::cout << string << std::endl ;    std::cout << str1 << std::endl ;} 

读书人网 >C++

热点推荐