Skip to main content

Featured

Build docker image from multiple build contexts

Build docker image from multiple build contexts Building a docker image requires specifying a source of truth to include in the image from a local directory or a remote git repository. In the previous version, the docker BuildKit allows users to specify the build context from a single source of truth only. However, the engineers may need to have the context from different locations based on the type of files. For instance, icons, images or other resources that are not included in the same package, including the resource from other docker images. Fortunately, the Docker Buildx toolkit supports multiple build context flag for Docker 1.4. Let's learn how to use this new feature. The following list is a shortcut for jumping into a specific topic handy. What version of Docker is this tutorial targeting? How to specify the version of Dockerfile frontend? Ho

[C]快速判斷字串是否為空字串

寫法很簡單,就像下列寫法:
if(*szStr)
{
  ....
}

因為*szStr == szStr[0],且char[]是以NULL-Terminate來判定字串是否結束,所以只要判定陣列的第一個值是不是為零,就可知道是否為空字串。
如需檢查是否為空字串則在指標前面加上NOT operator即可。

相同的方法也可以應用在其他的陣列結尾檢查,例如:
for ( int i = 0 ; arrVar[i] ; i++ )
{
    ....
}
 


按照Jacob的說法,只要在陣列的結尾塞個0,或是NULL,當迴圈跑到false或是NULL的時候,就會自動結束,這樣也就減少了 n個 if檢查。

Comments

Popular Posts