大家好,我在vc自带的帮助MSDN中找stract 与strcpy的用法,根据我的理解strcpy(a,b)就是把b的内容拷贝到a中,那么strcat()的用法呢??
------------------------------------------------------------------------
我在vc自带的帮助MSDN中找stract 与strcpy的用法,并且运行了MSDN自带的例子
#include <string.h>
#include <stdio.h>void main( void )
{
   char string[80];
   strcpy( string, "Hello world from " );
   strcat( string, "strcpy " );
   strcat( string, "and " );
   strcat( string, "strcat!" );
   printf( "String = %s\n", string );
}
---------------------------------------------
运行时出错
D:\myproject\example\example.cpp(6) : error C2065: 'strcpy' : undeclared identifier
D:\myproject\example\example.cpp(7) : error C2065: 'strcat' : undeclared identifier
Error executing cl.exe.example.obj - 2 error(s), 0 warning(s)------------------------------------------------我的问题是1.stract 与strcpy的用法(重点是strcat)
          2.运行时出错信息说strcpy,strcat末定义,我应在哪定义呀??

解决方案 »

  1.   

    你是 vc几啊,是不是.net?我vc++6可以的。1.stract 与strcpy的用法(重点是strcat)怎么用我觉得还是自己去测试一下比较好。
              2.运行时出错信息说strcpy,strcat末定义,我应在哪定义呀??
      

  2.   

    strcpy( string, "Hello world from " ); //string为"Hello world from " 
       strcat( string, "strcpy " );//string为"Hello world from strcpy" 
       strcat( string, "and " );//string为"Hello world from strcpy and " 
       strcat( string, "strcat!" );//string为"Hello world from strcpy and strcat" 
      

  3.   

    strcpy( string, "Hello world from " ); //string为"Hello world from " 
       strcat( string, "strcpy " );//string为"Hello world from strcpy" 
       strcat( string, "and " );//string为"Hello world from strcpy and " 
       strcat( string, "strcat!" );//string为"Hello world from strcpy and strcat" 
      

  4.   

    strcat是将一个字符串加到一个字符串后,得到一个新的字符串.
    如:
    strcpy( string, "Hello world from " );
    strcat( string, "strcpy " );strcpy相当于给字符串变量赋值.
    字符串开始是"Hello world from " ,strcat函数将"strcpy " 加到其后,得到新的字符串
    "Hello world from strcpy "
       
      

  5.   

    -------------------Configuration: Cpp1 - Win32 Debug--------------------
    Compiling...
    Cpp1.cppCpp1.obj - 0 error(s), 0 warning(s)