C ++ primer plus Study Notes (5)

Source: Internet
Author: User

1. logical expressions

1. | the operator is a sequence point ).

First, modify the value on the left and then judge the value on the right. For example, I ++ <6 | I = J

First I ++ and then I = J;

2. The priority of the & operator is lower than that of the relational operator.


2. Simple file input and output

Assume that the following example is input: 38.5 19.2

1. Char ch; CIN> CH

The encoding of character 3 is not stored here.

2. Int N; CIN> N;

Cin will continue to read until non-numeric characters are encountered. For example, click. Here.

3. Char word [50]; CIN> word;

Here, the CIN is continuously read until blank characters are encountered.

4. Char word [50]; cin. Getline (word, 50 );

Here, CIN keeps reading until a line break is encountered.


3. file output operation steps:

1. Declare An ifstream variable (object ). Associate objects with files. For example, open ().

2. You can use the ifstream object and operator <to read various types of data.

3. You can use an ifstream object and get () to read a single character and use Getline () to read a row.

4. Check whether the input is successful by combining EOF () and fail.

5. Good () checks whether an error occurs, such as EOF or file downloading.

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.