| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 444 人关注过本帖
标题:怎么在VC++6.0调试界面上输入一组文本行?
只看楼主 加入收藏
t495647533
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2014-10-17
结帖率:66.67%
收藏
 问题点数:0 回复次数:0 
怎么在VC++6.0调试界面上输入一组文本行?
例如在下列一组文本中查找包含字符串"ould"的行。
Could you do me a favor?
Yeah,go ahead.
Thank you. would you please bring a book about c?
ok,I'll take it for you tomorrow.
程序执行过后的输入结果:
Could you do me a favor?
Thank you. would you please bring a book about c?
程序的源代码入下在下面,问题是我的输入总是一行一行的,不是一起输入一组文本行后在判断。就像我输入第一句后就直接判断输出了。程序然后就结束了。高手们能不能帮我改一下啊。
#include<stdio.h>
#define MAXLINE 1000   /* maximum input line length */

int getline(char line[],int max);
int strindex(char source[],char searchfor[]);

char pattern[] = "ould";  /* pattern to search for */

/* find all lines matching pattern */
int main()
{
    char line[MAXLINE];
    int found = 0;

    while(getline(line,MAXLINE) > 0)
    {
        if(strindex(line,pattern) >= 0){
            printf("%s",line);
            found ++;
        }
        return found;
    }
}

/* getline: get line into s,return length */
int getline(char s[],int lim)
{
    int c,i;
    i = 0;
    while(--lim>0 && (c=getchar())!=EOF && c!='\n')
        s[i++] = c;
    if(c == '\n')
        s[i++] = c;
    s[i] = '\0';
    return i;
}

/* strindex: return index of t in s,-1 if none */
int strindex(char s[],char t[])
{
    int i,j,k;
    for(i=0;s[i]!='\0';i++)
    {
        for(j=i,k=0;t[k]!='\0' && s[j]==t[k];j++,k++)
            ;
        if(k>0 && t[k]=='\0')
            return i;
    }
    return -1;
}
搜索更多相关主题的帖子: include 源代码 please 字符串 about 
2015-03-26 16:11
快速回复:怎么在VC++6.0调试界面上输入一组文本行?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013529 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved