Fundamentals of C + + programming 122-combining assignment operators and relational operators

Source: Internet
Author: User
Tags strcmp

1 //22-Combination assignment operator and relational operator. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7#include <array>8#include <string>9 using namespacestd;Ten  One intMain () A { -     // + - * / -     //+ = = *=/=%= combination assignment operator the     intA = at, B = in; -A + = B;//a=a+b; -cout << a <<Endl; -A-=b; +cout << a <<Endl; -a*=b; +cout << a <<Endl; AA/=b; atcout << a <<Endl; -A%=b; -cout << a <<Endl; -  -     //> >= < <= = = = = Relational operator -     BOOLres = the> the; incout << Res <<Endl; -     intE = -, f= -; tocout << (E > F) <<Endl; +  -     //string comparison the     CharStr1[] ="Uimodel"; *     CharStr2[] ="Uimode1"; $cout << (str1 = = str2) <<endl;//The array itself is a pointer, in different addresses, the default comparison is the address, so the values are not equal, 0 is false. Panax Notoginseng     //What if the data in the string (pointer) address is judged to be the same?  -strcmp (str1, str2);//The comparison is the value in the string address, 0 equals not 0 thecout << strcmp (str1, str2) << Endl;//If you are comparing a C-style string, you need to compare it with the strcmp function.  +  A     //C + + style string Direct comparison on the line the     stringSTR3 ="Uimodel1"; +     stringSTR4 ="Uimodel2"; -cout << (Str3 = = STR4) << Endl;//false, the output result is 0.  $  $     intT; -CIN >>T; -     return 0; the}

Fundamentals of C + + programming 122-combining assignment operators and relational operators

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.