error C2065: 'strlen' : undeclared identifier该怎么解决?

程序代码是:
#include <stdio.h>
#include <malloc.h>
#define Stack_Size 20
typedef int ElemType;
typedef struct
{ElemType elem[Stack_Size];int top;
} SeqStack;
void InitStack(SeqStack *S)
{S->top=-1; printf("kong zhan S=( )\n");}
int IsEmpty(SeqStack *S)
{if(S->top==-1) return 1;else return 0;}
int IsFull(SeqStack *S)
{if(S->top==Stack_Size-1) return 1;else return 0;}
int Push(SeqStack *S,ElemType x)
{if(IsFull(S)) return 0;
S->top++;S->elem[S->top]=x;
return 1;
}
int Pop(SeqStack *S,ElemType *x)
{if(IsEmpty(S)) return 0;
*x=S->elem[S->top];S->top--;
return 1;
}
void ClearStack(SeqStack *S)
{free(S);printf("zhan xiao hui \n");}

void main ()
{char x[20];int Mx;int M;
int m;int X=0;int t;int i,length;
SeqStack *S=(SeqStack *)malloc(sizeof(SeqStack));
InitStack(S);
printf("qing shu ru jin zhi he shu :");
scanf("%d,%s",&Mx,x);
t=1;
length=strlen(x);
for(i=0;i<length;i++)
{ if(x[i]>='a'&&x[i]<='z')
Push(S,x[i]-'a'+10);
else
Push(S,x[i]-'0');
}
while(!IsEmpty(S))
{Pop(S,&m);X+=m*t;t*=Mx;}
printf("shi jin zhi shu=%d\n",X);
do
{printf("zhuan huan de jin zhi :");
scanf("%d",&M);
}while(M<0||M>16||M==Mx);
while(X!=0)
{m=X%M;Push(S,m);X=X/M;}
printf("%d jinzhi zhuan huan cheng %d zhi de zhi : ",Mx,M);
while(!IsEmpty(S))
{Pop(S,&m);
if(m>=10)printf("%c",'a'+m-10);
else printf("%d",m);
}
printf("\n");
ClearStack(S);
}
感激不尽~~

开头的时候您没有对其定义 在 #include <malloc.h> 之后加上 #include <string.h> 就可以了,帮您试验了一下 z.obj - 0 error(s), 0 warning(s) 结果完全通过~ 请采纳哦
#include <stdio.h>
#include <malloc.h>
#include <string.h>
开头就是这样样子
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-07-28

开头的时候没有对其定义

在  #include <malloc.h>   

之后加上  #include <string.h>

C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。

尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。

二十世纪八十年代,为了避免各开发厂商用的C语言语法产生差异,由美国国家标准局为C语言制定了一套完整的美国国家标准语法,称为ANSI C,作为C语言最初的标准。 目前2011年12月8日,国际标准化组织(ISO)和国际电工委员会(IEC)发布的C11标准是C语言的第三个官方标准,也是C语言的最新标准,该标准更好的支持了汉字函数名和汉字标识符,一定程度上实现了汉字编程。

第2个回答  2011-10-17
#include <string.h>
在文件开头包含这个头文件,里面是关于字符串操作的函数。
#include <stdio.h>
#include <malloc.h>
#include <string.h>
开头那里改成这样
第3个回答  2011-10-13
#include <string.h>
第4个回答  2013-02-13
请问这是什么程序?
相似回答