当前位置: 动力学知识库 > 问答 > 编程问答 >

c - I saw some code in "return" that i don't understand. Can somebody help me?

问题描述:

Is there any doc i can read about this kind of function?

// return the capital of char c

char a(char c){

return c >= 'a' && c<='z' ?

c +'A' - 'a':c;

}

网友答案:

Read up on the ternary operator. :) And then it will be clear the code is doing:

if (c >= 'a' && c<='z') {
   return(c +'A' - 'a');
} else {
    return c;
}

So basically it is capitalizing the Latin alphabet in ASCII.

分享给朋友:
您可能感兴趣的文章:
随机阅读: