栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

linux小知识点

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux小知识点

linux小知识点
  • 一、linux线程
      • (1)线程库
  • 二、C语言
      • (1)ifndef
      • (2)short unsigned int 的scanf及printf格式

一、linux线程 (1)线程库

参考文献

linux中线程属于第三方库开发
安装线程库man手册:
sudo apt-get install manpages manpages-dev
sudo apt-get install manpages-posix-dev
编译:
gcc -o bin src.c -lpthread //指定线程库链接

如果不安装这个,man pthread_mutex_init 就没有条目。

二、C语言 (1)ifndef

标识的命名规则一般是头文件名全大写,前后加下划线,并把文件名中的“.”也变成下划线,如:stdio.h

#ifndef _STDIO_H_
#define _STDIO_H_

#endif

(2)short unsigned int 的scanf及printf格式

参考文献1

For scanf, you need to use %hu since you’re passing a pointer to an
unsigned short. For printf, it’s impossible to pass an unsigned short
due to default promotions (it will be promoted to int or unsigned int
depending on whether int has at least as many value bits as unsigned
short or not) so %d or %u is fine. You’re free to use %hu if you
prefer, though.

参考文献2
对于printf

A format specifier follows this prototype:
%[flags][width][.precision][length]specifier


对于scanf

A format specifier for scanf follows this prototype:
%[*][width][length]specifier

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/303101.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号