Files
BlogPosts/Collection/连~都忘记了的小知识.md

27 lines
778 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
tags:
- C语言
- Linux
aliases:
- 小知识
日期: 2026/1/23
---
- 字符类型数字转整形数字要 `-'0'`
```c
char arr[10];
for(int i = 0;i < strlen(arr);i++)
num = num * 10 + arr[i] - '0';
```
- Linux重新加载配置文件命令
```shell
shource ~/.bashrc #重载bashrc文件
```
- Linux写脚本
```shell
vim mount_hgfs
sudo vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other #填入命令
chmod +x mount_hgfs #增加执行权限
mv mount_hgfs /bin #移动到/bin路径下 以后使用 mount_hgfs 直接执行
```
- C语言`&&`运算符的左值为假时,右值不进行计算,同理`||`运算符左值为真右值不进行计算
- 按位异或`^a ^ b = c , a ^ c = b , b ^ c = a;`,可用于进行数的交换(省去中间值)