帮忙看看是哪错了

guozhenfeilaier 2008-07-27 08:38:11
下面是代码及错误提示,帮忙改改,我实在是没辙了。看不懂错误提示。

--------------------Configuration: feifei - Win32 Debug--------------------
Compiling...
指针连接字符串.c
E:\三级\my project\feifei\指针连接字符串.c(9) : warning C4013: 'strlen' undefined; assuming extern returning int
E:\三级\my project\feifei\指针连接字符串.c(16) : error C2143: syntax error : missing ';' before 'type'
E:\三级\my project\feifei\指针连接字符串.c(19) : error C2143: syntax error : missing ';' before 'type'
E:\三级\my project\feifei\指针连接字符串.c(20) : error C2143: syntax error : missing ';' before 'type'
E:\三级\my project\feifei\指针连接字符串.c(23) : error C2065: 'ch' : undeclared identifier
E:\三级\my project\feifei\指针连接字符串.c(23) : error C2065: 's1' : undeclared identifier
E:\三级\my project\feifei\指针连接字符串.c(23) : error C2100: illegal indirection
E:\三级\my project\feifei\指针连接字符串.c(28) : error C2065: 's2' : undeclared identifier
E:\三级\my project\feifei\指针连接字符串.c(28) : error C2100: illegal indirection
E:\三级\my project\feifei\指针连接字符串.c(29) : error C2100: illegal indirection
E:\三级\my project\feifei\指针连接字符串.c(29) : error C2106: '=' : left operand must be l-value
E:\三级\my project\feifei\指针连接字符串.c(31) : error C2065: 'dest' : undeclared identifier
E:\三级\my project\feifei\指针连接字符串.c(33) : error C2059: syntax error : '}'
执行 cl.exe 时出错.

feifei.exe - 1 error(s), 0 warning(s)


#include<stdio.h>
#include<stdlib.h>
char*strCat(register char*dest,register const char*src);
int main(void)
{
char strDest[161]="you are";
char strName[81];
puts("please enter your name:");
while((strlen(strDest)<80) && strlen(gets(strName)))
{
strCat(strDest,strName);
printf("%s\n",strDest);
system("pause");
return 0;
}
char*strCat(register char*dest,register const char*src)
{
register char*s1=dest;
register const char*s2=src;
register char ch;
do
{
ch=*s1++;
}while(ch!='\0');
s1-=2;
do
{
ch=*s2++;
*++s1=ch;
}while(ch!='\0');
return dest;
}
}
...全文
82 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
coverallwangp 2008-07-28
  • 打赏
  • 举报
回复

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char*strCat(register char*,register const char*);
int main(void)
{
char strDest[161]="you are";
char strName[81];
puts("please enter your name: ");
while((strlen(strDest) <80) && strlen(gets(strName)))
{
printf("%s\n",strCat(strDest,strName));
}
system("pause");
return 0;
}
char*strCat(register char*dest,register const char*src)
{
char*s1=dest;
const char*s2=src;
char ch;
do
{
ch=*s1++;
}while(ch!='\0');
s1-=2;
do
{
ch=*s2++;
*++s1=ch;
}while(ch!='\0');
return dest;
}
wangydong 2008-07-28
  • 打赏
  • 举报
回复
都是最基本的错误。
lala_benben 2008-07-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 yangkunjie 的回复:]
引用 2 楼 ttkk_2007 的回复:
这么简单的英语看不懂?
缺#include <string.h>
语法错误


[/Quote]
heroful 2008-07-28
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char*strCat(char*,const char*);
int main(void)
{
char strDest[161]="you are";
char strName[81];
puts("please enter your name: ");
while((strlen(strDest) <80) && strlen(gets(strName)))
{
printf("%s\n",strCat(strDest,strName));
}
system("pause");
return 0;
}
char*strCat(char*dest, const char*src)
{
char*s1=dest;
const char*s2=src;
char ch;
do
{
ch=*s1++;
}while(ch!='\0');
s1-=2;
do
{
ch=*s2++;
*++s1=ch;
}while(ch!='\0');
return dest;
}
yangkunjie 2008-07-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ttkk_2007 的回复:]
这么简单的英语看不懂?
缺#include <string.h>
语法错误
[/Quote]
deerwin1986 2008-07-27
  • 打赏
  • 举报
回复
这个...怎么这么多register啊 那个是寄存器变量 在X86机器上貌似没什么用处 而且很多优化编译器会给你做的 所以把这些去掉再试一下吧
guozhenfeilaier 2008-07-27
  • 打赏
  • 举报
回复
不会改啊 各位 帮个忙吧
guozhenfeilaier 2008-07-27
  • 打赏
  • 举报
回复
看不懂啊
ttkk_2007 2008-07-27
  • 打赏
  • 举报
回复
这么简单的英语看不懂?
缺#include <string.h>
语法错误
BoyMgl 2008-07-27
  • 打赏
  • 举报
回复
不是都写着了吗?

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧