"C language" in the terminal to enter multiple lines, find "Ould" line, and print.

Source: Internet
Author: User

<pre name= "code" class= "CPP" >/* enter multiple lines of information in the terminal, find the line containing "Ould" and print a row such as: Au,love could you and I with fate conspireto grasp thi s sorry scheme of things entire,would not we shatter it to bitd-and then. Output the above text in the terminal, output au,love could you and I with fate Conspirewould not we shatter it to Bitd-and then.*/#include <stdio.h> #define MAXLINE 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;      } int Compare (char Line[],char str[]) {int i,j,k;              for (i = 0;line[i]! = ' + '; i++) {for (j = i,k = 0;str[k]!= ' + ' &&          Str[k] = = line[j];j++,k++) {;      } 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 language" in the terminal to enter multiple lines, find "Ould" line, and print.

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.