strcpy,strcmp等C语言函数不能用 我在头文件中已包括了stdio.h, 但是还是不能用strcpy,strcmp等C语言函数,报错strcpy,strcmp等未定义.我原来是能用了,最近用一个开发包,其中包含了一些头文件就不能用了,不知这跟64位的软件有没有问题.我用的是32位的系统(开发包可能是64位的).这个工程一直是用C开发的,开发包也是用C写的.希望各位能帮我解决一下.谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个是头文件string.h里的,如果不是string.h,也是别的头文件,你是头文件有问题API里也有功能相仿的,windows.h里有lstrcat、lstrcpy 我用的是32位的系统(开发包可能是64位的).这个工程一直是用C开发的,开发包也是用C写的.如果开发包可能是64位的,那不能用到32位的系统中。楼上的对:这个是头文件string.h里 Tool菜单下的Options下的Directories下把路径添加进去 这两个函数是头文件:#include <string.h><stdio.h>中包含的是:标准输入输出函数; [Quote=引用 7 楼 shexinwei 的回复:]这两个函数是头文件:#include <string.h><stdio.h>中包含的是:标准输入输出函数; 开发包可能是64位的)?有点困惑。即使是64位的有人应该向下兼容的。/* STRCPY.C: This program uses strcpy * and strcat to build a phrase. */#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 );}OutputString = Hello world from strcpy and strcat!MSDN上面的例子 #include <stdio.h>#include <string.h>... #include <stdio.h>#include <string.h>两个头文件都要包括 谢谢,这那多人来解答,错误是这样的:说strcpy未定义,但是我用Go to Definition of strcpy 又能够打开STRING.H文件,并指向了strcpy 的定义函数 #include <stdio.h>#include <string.h>两个头文件都要包括 char* strcpy(char * strDest,const char * strSrc){ if ((strDest==NULL)||(strSrc==NULL)) return NULL; char* strDestCopy=strDest; while ((*strDest++=*strSrc++)!='\0'); return strDestCopy;}int strcmp(char* s,char* t){ while(*s&&*t&&*s==*t) { s++; t++; } return (*s-*t);} 对,应该是#include <string.h>!!! 如果是用的vs2005之类的,貌似要用clr创建任务 项目属性中的character set选择的是unicode character还是multi-byte character 前几天我用#include<math.h>还报错呢,而且仅仅包含了一下这个math.什么也没调用,原因后来找到了,是因为我还包含了其他一些库的头文件,应该在包含其他库之前,先包含math.h. #include <string.h>str的函数呀~~ #include <stdio.h>#include <string.h>两个头文件都要包括 // test.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "string.h"int _tmain(int argc, _TCHAR* argv[]){ char a[200]; char z[100] ; strcpy(a, z); if (strcmp(a, z)); return 0;}编译通过 谢谢大家的热情回贴,是因为没有包含string.h的原因,因为我原来是没有包含的,现在软件开发包做了升级所以要包含了,我一时没想到,谢谢,现在就结贴,只要分够,人人都有分。 求助白色画刷上输出文本问题 屏幕上画图问题 有关CString转换成int数组的问题 VC的ATL编COM组件,Com之间调用问题 窗口右上角的三个小按钮,如何设置Enable或Disable? 和公司续约2年,也涨工资了,开心,散分!!! 请问哪里有表格原代码下载?? 求助:实时控制程序中曲线的绘制! 操作系统原理课程设计 为什么我的控件会出现这个问题? 跪求_tcsstr()函数的源代码 CSerialPort类 和 mscom控件 不能同时使用
API里也有功能相仿的,windows.h里有lstrcat、lstrcpy
<stdio.h>中包含的是:标准输入输出函数;
这两个函数是头文件:#include <string.h>
<stdio.h>中包含的是:标准输入输出函数;
* and strcat to build a phrase.
*/#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 );
}
OutputString = Hello world from strcpy and strcat!
MSDN上面的例子
#include <string.h>
...
#include <string.h>
两个头文件都要包括
#include <string.h>
两个头文件都要包括
char* strcpy(char * strDest,const char * strSrc)
{
if ((strDest==NULL)||(strSrc==NULL)) return NULL;
char* strDestCopy=strDest;
while ((*strDest++=*strSrc++)!='\0');
return strDestCopy;
}
int strcmp(char* s,char* t)
{
while(*s&&*t&&*s==*t)
{
s++;
t++;
}
return (*s-*t);
}
str的函数呀~~
#include <string.h>
两个头文件都要包括
//#include "stdafx.h"
#include "string.h"int _tmain(int argc, _TCHAR* argv[])
{
char a[200];
char z[100] ; strcpy(a, z);
if (strcmp(a, z));
return 0;
}
编译通过