青灯古佛 发表于 2016-4-30 19:39:21

读取输入行的第一个单词

//自定义函数-readfw读入输入行中的第一个单词
#include <stdio.h>
#include <string.h>
void readfw(char *str1,char *str2);
#define LENGTH 80
int main (void)
{
        char str2;
        char str1;
        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'<91)&&('str1'>64))||(('str1'<123)&&('str1'>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)
页: [1]
查看完整版本: 读取输入行的第一个单词