9.23笔试总结

C语言的一些小东西,长时间没用忘得差不多了:

#include<iostream>
using namespace std;
int main()
{
    int m = 5;
    int n = 6;
    n += n -=m *= n;
    cout <<"n:"<< n<<endl;
    int k = 0;
    char a;
    char b[] = "hello";
    char* p = b;
    cout << "a:"<<sizeof(a)<<"b:"<<sizeof(b)<<"c:"<<sizeof(p);
    return 0;

+= -= *=这类是从右往左

char类型的指针,sizeof()结果是4,sizeof一个长度为5的字符数组"hello" 结果是6,因为到“\0”结束 

循环赋值,这样写没错。

猜你喜欢

转载自www.cnblogs.com/xingzhuan/p/11576070.html