cout and printf

Source: Internet
Author: User

#include <iostream>using namespacestd;intMain () {intI=0, j=0; cout<<i++<<"\ t"<<i++<<"\ t"; cout<<i++<<Endl; printf ("j++\tj++\t"); printf ("j++\n"); return 0;}

VC6.0

#include <iostream>using namespacestd;inthello1 ();intHello2 ();intMain () {intA, B; cout<<"a="<"b="<Endl; printf ("a=%d b=%d\n", Hello1 (), Hello2 ()); return 0;}intHello1 () {cout<<"Hello1"<<Endl; return 1;}intHello2 () {cout<<"Hello2"<<Endl; return 2;}

VC6.0

The sequence of operations for the cout stream is:

Read the buffer from right to left and then output from left to right. So when it reads from the right to the left, it touches the function of course to execute the function first, and then reads the function return value into the buffer and then ... is the output from the left.

Looks like the compiler has different results, so you need to standardize your own input and output

cout and printf

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.