C Language Learning 006: Song search and language learning 006

Source: Internet
Author: User

C Language Learning 006: Song search and language learning 006

1 # include <stdio. h> 2 # include <string. h> // string processing database 3 4 char tracks [] [80] = {5 "I left my heart in Harvard Med School", 6 "Newwark, newwark-a wonderful town ", 7" From here to maternity ", 8" The girl from Iwo Jima ", 9}; 10 11 void find_track (char search_for []) {12 int I; 13 for (I = 0; I <5; I ++) {14 if (strstr (tracks [I], search_for) // strstr string search, if the position of the returned string in the memory is found, if not, the return value is 015 printf ("Track % I: '% s' \ n", I, tracks [I]). 16} 17} 18 19 int main () {20 char search_for [80]; 21 printf ("Search for:"); 22 fgets (search_for, 80, stdin ); 23 search_for [strlen (search_for)-1] = '\ 0'; // strlen returns the string length 24 find_track (search_for); 25 return 0; 26}

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.