C语言
椰子猫qqqy
C语言学习中
展开
-
C语言写printf函数太长按回车,字符串常量中有非法字符
在C语言中打印比较长的字符串时(打印内容过长且回车报错) 如:printf(“hello world”); 虽然C编译器会忽略多余的空白,但是不能在双引号括起来的字符串中间断行。 在CPRIMER上看到的三种断行方法如下: printf("Here’s one way to print a "); printf(“long string”); printf(“another way to prin...原创 2019-05-16 11:34:21 · 1599 阅读 · 0 评论 -
sizeof和strlen() 和 size_t 梳理
在C语言中,获得某串的长度是一项基本的技能,下面整理一下sizeof,strlen和size_t的用法和区别。 作用 使用方法 举例 备注 性质 sizeof 统计字符串占用字节数量 sizeof (类型) / sizeof 变量 sizeof(int);sizeof bianliang; 统计类型必须要括号 运算符 strlen 统计非空字符串字节数量 strlen(变量)...原创 2019-04-17 11:39:01 · 518 阅读 · 0 评论 -
CPRIMER PLUS 8.2 在遇到EOF之前,把输入作为字符流读取。程序要打印每个输入的字符以及相应的ASCII十进制值
#include<stdio.h> void put(char c); int main(void) { int i = 0; int ch; int j; int permit = 1; int ucount = 0;//可注释部分 while((ch = getchar())!=EOF)//作为字符流的输入,getchar()把在遇到换行符之前的输入作为一个字节流 {...原创 2019-05-16 11:30:25 · 932 阅读 · 0 评论 -
在Visual Stidio 命令行中编译多源代码文件的C语言程序
核心命令:cl mainfile.c subfile.c 头文件无需编译 以下是CPRIMER 中的案例: 控制模块: /* usehotel.c -- room rate program */ /* compile with Listing 9.10 */ #include <stdio.h> #include "hotel.h" //* defines consta...原创 2019-05-21 19:07:11 · 227 阅读 · 1 评论 -
C语言 VS2017不支持变长数组
#include<stdio.h>//传统方式和变长方式 void T_trots(double ar[],int n); //void Vla_trots(int n, double ar[n]);//VS不支持变长数组 int main(void) { double trots[20]; short clops[10][30]; long shots[5][10][15];...原创 2019-06-10 10:30:42 · 5312 阅读 · 0 评论