大家好,我在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末定义,我应在哪定义呀??
------------------------------------------------------------------------
我在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末定义,我应在哪定义呀??
2.运行时出错信息说strcpy,strcat末定义,我应在哪定义呀??
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"
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"
如:
strcpy( string, "Hello world from " );
strcat( string, "strcpy " );strcpy相当于给字符串变量赋值.
字符串开始是"Hello world from " ,strcat函数将"strcpy " 加到其后,得到新的字符串
"Hello world from strcpy "
Compiling...
Cpp1.cppCpp1.obj - 0 error(s), 0 warning(s)