Answer the question
In order to leave comments, you need to log in
Changes function arguments! What is it like?
Here's an example from the book:
#include <stdio.h>
#define MAXL 1000
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;
}
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;
}
int main(int argc, char const *argv[])
{
char pattern[]="ould";
char line[MAXL];
char found=0;
while(getline(line, MAXL)>0)
if(strindex(line, pattern)>=0){
printf("Нашли: %s", line);
found++;
}
return found;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question