"C" Enter multiple lines of information in the terminal, find the line containing "Ould", and print the row

Source: Internet
Author: User

/* Enter multiple lines of information in the terminal, locate the line containing "Ould", and print the row. such as: Au,love could you and I with fate Conspireto grasp the sorry scheme of things entire,would not we shatter it to BITD- And then. Output the above text in terminal, output au,love could you and I with fate conspirewould not we shatter it to Bitd-and then.*/#include &lt  ;stdio.h> #define MAXLINE 1000//gets to a line of characters to determine whether to get to a row and put it into an array inside prepare to compare int getline (char ar[],int max) {int       Ch       int i = 0;           while ((ch = getchar ())! = EOF && ch! = ' \ n ' && i < max) {ar[i] = ch;       i++;       } if (ch = = ' \ n ') ar[i++] = ch;       Ar[i] = ' + ';   return i;       }//Compare to determine if there is no target string int compare (char Line[],char str[]) {int i,j,k; for (i = 0; Line[i]! = ' + '; i++) {//Where I is identified by a J and let J go backwards to compare with K for (j = i,k = 0; str[k]! = ' && ' Amp Str[k] = = Line[j];           j++,k++) {;         }//If k is moved and K does not go to the last indication of successful if (k>0 && str[k] = = ' + ')      return 1;   } return 0;          } int main () {char line[maxline];                Char str[] = "ould";          while (Getline (line,maxline)) {if (compare (LINE,STR)) printf ("---%s\n", line);      } return 0; } 

"C" Enter multiple lines of information in the terminal, find the line containing "Ould", and print the row

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.