|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
//自定义函数-readfw读入输入行中的第一个单词
#include <stdio.h>
#include <string.h>
void readfw(char *str1,char *str2);
#define LENGTH 80
int main (void)
{
char str2[LENGTH];
char str1[LENGTH];
puts("enter some words within one line");
gets(str1);
readfw(str1,str2);//读取第一个单词并将其保存在str2中
puts("now this is the result of function readfw");
puts(str2);//输出该单词
return 0;
}
void readfw(char *str1,char *str2)
{
int i=0;
while ((('str1[i]'<91)&&('str1[i]'>64))||(('str1[i]'<123)&&('str1[i]'>91)))
{
*(str2+i)=*(str1+i);
i++;
}
}
下面是编译结果:
fjied.c
D:\vc++6.0\Microsoft Visual Studio\MyProjects\jdskjfi\fjied.c(20) : error C2015: too many characters in constant
D:\vc++6.0\Microsoft Visual Studio\MyProjects\jdskjfi\fjied.c(20) : error C2015: too many characters in constant
D:\vc++6.0\Microsoft Visual Studio\MyProjects\jdskjfi\fjied.c(20) : error C2015: too many characters in constant
D:\vc++6.0\Microsoft Visual Studio\MyProjects\jdskjfi\fjied.c(20) : error C2015: too many characters in constant
Error executing cl.exe.
jdskjfi.exe - 4 error(s), 0 warning(s)
|
|