C Language Learning: Pipeline Connection input and output, language learning

Source: Internet
Author: User

C Language Learning: Pipeline Connection input and output, language learning

Now, you need to filter the data in the gpsdata.csv file and output the data that meets the criteria to output. in a json file, the first method is to modify the previous code. But if we don't want to modify the original code, we can get the expected results. How can we achieve this?

42.0908,-71.2316, speed = 2137.1908,-74.2322, speed = 1942.0908,-71.3312, speed = 2044.5908,-70.2314, speed = 1739.0908,-62.2512, speed = 1943.0908,-60.1311, speed = 1645.0908,-65.2316, speed = 20

We need to use pipelines to connect the standard output of a process to the standard input of another process, and use the "|" symbol to represent it.

Now let's implement the code of conditional handsome selection. we name the program bermuda

1 # include <stdio. h> 2 3 int main () {4 float latitude; 5 float longpolling; 6 char info [80]; 7 while (scanf ("% f, % f, % 79 [^ \ n] ", & latitude, & longpolling, info) = 3) {8 if (latitude> 40) & (latitude <44 )) {// filter condition 9 printf ("% f, % f, % s \ n", latitude, longpolling, info); 10} 11} 12 return 0; 13}

Finally, we can see that the output. json file contains data that meets the conditions (latitude> 40) & (latitude <44 ).

The advantage of pipelines is that we can separate each small program to complete its own single task and decouple the program.

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.