包含标签 C语言 articles

条件运算符?:的使用

C语言中的三目运算符?:的使用往往能减少代码的书写,达到事半功倍的效果,如下面的代码,前面先定义了一个求得最大值的函数max,使用到了?:用于比较三个整型数字的大小。 #include <stdio.h> int max(int x,int y,int z) { int m; m=(x>y)?x:y; /*当x>y为真时,m取x的值,为假时取y的值 */ m=(m>z)?m:z; return m; } main() { int a,b,c,m; scanf(“%d,%……

Continue reading

strcmp、strcpy函数的用法

例子代码: #include <stdio.h> #include <string.h> main() { char s1[10]=”China”; char s2[10]=”America”; char s3[10]=”Japan”; char t[10]; if(strcmp(s1,s2)>0) { strcpy(t,s1);strcpy(s1,s2);strcpy(s2,t); } if(strcmp(s2,s3)>0) { strcpy(t,s2);strcpy(s2,s3);strcpy(s3,t); } puts(s1);puts(s2);puts(s3); } strcmp字符串的比较,strcpy字符串的拷贝。 运行结果: [nagios@TestServer-RHAS-5 c]$ ./daima3 America China Japan 详细用法见下面的解释页面。 http://baike.baidu.com/view/1026924.htm http://baike.baidu.com/view/1026861.htm……

Continue reading

if控制语句的例子

C语言中if控制语句的例子 第一个例子,三个数中求最大的: #include <stdio.h> main() { int a,b,c; int max; printf(“input 3 values of integer:”); scanf(“%d%d%d”,&a,&b,&c); if(a>b) max=a;else max=b; if(max<c) max=c; printf(“the max of %d,%d,%d is %d n”,a,b,c,max); } 第二个例……

Continue reading

scanf(), getchar(), 以及gets()函数注意点

本来想总结下几个常用标准输入与输出的函数的区别,可从网上找了下,一大堆别人总结好,而且总结的都很精炼,于是摘录下来学习下。 —————————————————- | 问题描述一:(分析scanf()和gets()读取字符) | —————————————————- scanf(), getchar()等都是……

Continue reading

C语言中的32个关键字

| 关键字 | 用 途 | 说 明 | |---|---|---| | auto | 存储种类说明 | 用以说明局部变量,缺省值为此 | | break | 程序语句 | 退出最内层循环 | | case | 程序语句 | Switch语句中的选择项 | | char | 数据类型说明 | 单字节整型数或字符型数据 | | const | 存储类型说明 | 在程序执行过程中不可更改的常量值 | | continue | 程序语句 | 转向下一次循环……

Continue reading

C语言运算符的优先级和结合性

优先级 运算符 运算符功能 运算类型 结合方向 最高 15 () —> 圆括号,函数参数表 数组元素下标 指向结构体成员 结构体成员 自左至右 14 ! ~ ++,– + – * & (类姓名) sizeof 逻辑非 按位取反 自增1,自减1 求正 求负 间接运算符 求地址运算符 强制类型转换 求所占字节数 单目运算 自右至左 13 *,/,% 乘,除,整数求余 双目运算……

Continue reading

Latest articles

Categories

Tags

ACL AD AES AI AWS Ansible Atlassian Azure BMC Blockchain Brocade CDH5 CL210 Cobbler Confd C语言 DDOS DISTINCT DNS Duckdb EKS ELK GCP Ghost Git Glusterfs Go Godaddy Grafana HBA HCIE Hotspot HttpWatch IBM IIS IOS InfluxDB Ingress InnoDB JavaScript Jinja2 KVM Keepalived Mplayer MySQLdb Netlify OpenResty PM PostgreSQL QoS RH318 RH442 RHCA RHCE RHEV RSA SRE SecureCRT Statuscode SublimeText2 TC Telecom Tencentcloud VBA aira2 alpine android anpic apache apm apparmor appfog apr apt-get aria2 array atop audit awk awstats axel backdoor backup bamboo bash bat benchmark bigdata bin bind bitwise book bootstrap bsd c1000 cache capistrano catlog centos centos7 chatops chattr check_mk checkinstall cisco clearall clickhouse cloud-desktop cmdb cms collectd comm compress conver corosync cpu crontab crunchbang css curl date decode dell desktop devops df dhcp diff diskpart django docker dos2unix dpkg drupal etcd excel fail2ban fastcgi fdisk fiddler find firewalld flask flvtool ftp function fuser geek gin github gitlab glances golang google gooupadd graphviz gravatra grep grub2 hadoop haproxy hardware heartbeat helm hexdump hhvm history html http/html/web httplogs https huawei huaweicloud hugo icmp iconv ifconfig inotify iopp ipmitool iptables iredmail iscsi isito it-news java jdk jenkins jira join joomla k3s k8s kdump kernel kingate lamp last leetcode lib light-http linux linux高级篇 ln ls lsi lsof lvm lvs mac mail man mark markdown matplotlib maven memcached microservice mimikatz mkdocs mkpasswd mmonit mod_jk mongodb monit monitor mono moodle mosh mount mpm mrtg mtr my.cnf mysql mysqlbinlog mysqld_multi mysqldump mysqlhotcopy nagios nc nethogs nexus nfs nginx nmon nocatlog node.js nrpe ntfs ntop ntp obs ocr open-falcon openbox opencv openldap openssl openstack oracle oswatch paas pacemaker pam pandas parted pcp pcre pdf percona perl pexpect pgrep php php-fpm ping plsql develope postfix powershell prettify proc prometheus puppeteer pushd pwgen pxe pyecharts python python模块 radmin raid rdesktop read redhat redis redmine regex rh134 rhel7 rhel8 rm rman rootkit route rpm rpmforge rrdtool rsync rsyslog safe saltstack samba scapy screen sed selenium selinux seo seq session set shc sheepdog shell shopt sitemap skydns smokeping snffier snmp socket soft sort spider sql sqlserver squid ss ssh sshpass strace strings su sudo suse svn sysbench syslog-ng sysstat systemd t tar tcpcopy tcpdump tech telnet tengine test testlink threads time tmux tomcat touch tr tsar twisted ubuntu udev ulimit unix unixbench user-agent useradd varnish vbs vercel vi vim visudo vmstat vmware vnc voice vpn vscode vsftp vsftpd vue watchdog web webcam webistrano wget wiki windows wol wordpress workshop wsl x-windows xampp xcache xmllint xtrabackup yule yum zabbix zeromq zip zonetime zookeeper 下载工具 云主机 云原生 代理 加密 古意 吐槽 圈里圈外 娱乐 字符串函数 安全 平台架构 意林 推理 提权 故事汇 故障案例 数据结构 每日看点 民国史 生活 科学记录 站长管理工具 算法 管理 网站架构 翻墙 股票 行业 诗韵 负载均衡 远程管理 面试题

Links

Meta