/*
时间:2017/8/9
地点:工程北629
功能:返回字符串t在s中最右边出现的位置。
思路:getchar() getline() strrindex() main()
思想:
*/
#include<stdio.h>
#define MAXLINE 1000 //数组最大值1000
int getline(char line[], int max); //函数原型
int strrindex(char source[], char searchfor[]); //函数原型
char pattern[] = "ni"; //字符数组,设置待查找的模式
/* 读入一行数据 */
int getline(char s[], int lim) //main发送line[]、MAXLINE两个实参,给s[]、lim两个形参
{
int c, i;
i = 0;
while(--lim > 0 && (c = getchar()) != EOF && c != '\n') //getline函数不同于“1.9节的getline函数”
s[i++] = c;
if(c == '\n')
s[i++] = c;
s[i] = '\0';
return i;
}
/* 返回字符串t在字符串s中最右侧的位置 */
int strrindex(char s[], char t[])
{
int i, j, k, r; //加入变量r
for(i = 0; s[i] != '\0'; i++)
{
for(j =