The learning situation this week

Source: Internet
Author: User
Tags strcmp

This week in general, most of the time is in the review of the previous period of knowledge, I think the front of the better understanding, is to the function of the time do not know how to separate, so every time to separate the time is difficult to start. Review the time has been to see this basically know how to use, and yesterday used the strcmp (comparison) how this use

12345678910 //题:比较字符串//要看ASII表 A:65,a:95#include<stdio.h>#include "1.c"intmain(void){    chara[] = "Aaa";    charb[] = "aa";    intnum = compare(a,b);    printf("%d",num);}

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 #include<stdio.h>intcompare(chara[],charb[]){    intbLenth,aLenth;//声明    inti = 0,j = 0,k = 0,num = 0;    into;        //计算字符数组的长度    while(a[i]!=‘\0‘){        i++;    }    aLenth = i;//计算字符数组a的长度    while(b[j]!=‘\0‘){        j++;    }    bLenth = j;//计算字符数组b的长度      //printf("a数组的长度为:%d,b数组的长度为:%d\n",aLenth+1,bLenth+1);          //谁短取谁    if(aLenth>=bLenth){        o = bLenth;//aLenth = i;赋值给o;    }else{        o = aLenth;//    }        //      for(k;k<o;k++){        if((int)a[k]>(int)b[k]){//将字符串转换成int型,            return1;        }elseif((int)a[k]==(int)b[k]){            num++;//            continue;        }else{            return -1;        }    }        //    if(num==o){        if(aLenth>bLenth){            return1;        }elseif(aLenth<bLenth){            return-1;        }        else{            return0;        }    }}

This is the use of strcmp. There is usually a little reading, yesterday review when a lot of theoretical knowledge can not be answered, and take one or two days to read more reading.

The learning situation this week

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.