首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

CCCCCCCCCCCC

行业研究 6.08MB 42 需要积分: 1
立即下载

资源介绍:

CC
.,
POINTERS ON C
-- --- ------ - -----------
1
A Quick Start
1.1 Introduction
It is always difficult to start describing a programming language because little
details do not make much sense until one knows enough to understand the "big
picture." In this chapter, I try to give you a glimpse of the big picture by looking at a
sample program and explaining its workings line by line. This sample program also
shows you how familiar procedures are accomplished in C. This information plus the
other topics discussed in the chapter introduce you to the basics of the C language so
that you can begin writing useful programs.
The program we dissect reads text from the standard input, modifies it, and
writes it to the standard output. Program l.l first reads a list of column numbers. These
numbers are pairs and indicate ranges of columns in the input line. The list is
terminated with a negative number. The remaining input lines are read and printed,
then the selected columns from the input lines are extracted and primed. Note that the
first column in a line is number zero. For example, if the input is
4 9 12 20 -1
abcdefghijklmnopqrstuvwxyz
Hello there, how are you?
I
am
fine,
thanks.
See you!
Bye
then the program would produce:
Original input
:
abcdefghijklmnopqxstuvwxyz
Rearranged
line:
efghijmnopqrstu
Chapter 1 A Quick Start
2
Original input
:
Hello
there,
how
are you?
Rearranged
line:
o ther
how
are
Original
input
: I
am
fine,
thanks.
Rearranged
line: fine,
thanks.
Original
input
:
See
you!
Rearranged
line:
you!
Original
input
:
Bye
Rearranged
line:
The important point about this program is that it illustrates most of the basic
techniques you need to know to begin writing C programs.
/*
** This program reads input lines from standard input and prints
**
each
input
line,
followed by
just
some
portions of the
line,
to
** the standard output.
**
**
The
first
input
is
a
lint of
column numbers, which ends with a
**
negative number. The column numbers are paired and
specify
**
ranges
of
columns from
the input line that are to
be
printed.
** For example, 0 3 10 12 -1 indicates
that
only columns 0 through 3
**
and columns 10
through
12
will
be
printed.
*/
#include <stdio.h>
#inc1ude <stdlib.h>
#include <string.h>
#define
MAX_COLS
20
/*
max
# of columns to process
*/
#define
MAX_INPUT
1000
/*
max
len of input
&
output lines
*/
int
read_column_numbers(
int
columns[],
int
max
);
void rearrange( char *output, char const
*input,
int
n_columns,
int
const columns[]
);
int
main( void
)
{
int
n_columns;
/*
#
of
columns
to
process
*/
int
columns[MAX_COLS];
/*
the columns
to
process
*/
char input[MAX_INPUT];
/*array for input line */
char output[MAX_INPUT];
/*array for
output
line */
Program 1.1 Rearrange characters continue.
1.1 Introduction
3
/*
**
Read the
list
of
column numbers
*/
n_columns = read_column_numbers( columns, MAX_COLS
);
/*
**
Read, process and
print
the remaining lines of input
*/
while( gets(input
)
!=
NULL
){
printf(
"Original input
:
%s\n", input
);
rearrange( output, input,
n_columns, columns
);
printf(
"Rearranged
line:
%s\n", output
);
}
returnEXIT_SUCCESS;
}
/*
**
Read
the
list
of
column numbers, ignoring any
beyond
the specified
** maximum.
*/
int
read_column_numbers(
int
columns[],
int
max
)
{
int
num =
0;
int ch;
/*
**
Get the numbers, stopping
at
eof
or
when a number
is
<
0.
*/
while(
num < max &&
scanf( "%d", &columns[num]
)
==
1
&&columns[num] >= 0
)
num +=1;
/*
**
Make
sure
we have an even number
of inputs,
as
they are
** supposed to be paired.
*/
if(
num
%
2
!=
0
){
puts( "Last
column number
is not paired."
);
exit(
EXIT_FAILURE
);
}
/*
** Discard the rest of the line that contained the
final
Program 1.1 Rearrange characters continue.
4
Chapter 1 A Quick Start
** number.
*/
while( (ch
=
getchar()) !=
EOF && ch
!=
'\n' )
;
return num;
}
/*
** Process a line of input by concatenating the characters from
**
the indicated columns.
The
output
line is
the
NUL
terminated,
*/
void
rearrange( char *output, char const
*input,
in n_columns,
int
const columns[]
)
{
int
col;
/*
subscript for
columns
array
*/
int
output_col;
/*
output column counter
*/
int
len;
/*
length of input line
*/
len
=
strlen( input
);
output_col
=
0;
/*
**
Process each
pair of
column numbers.
*/
for(
col = 0; col < n_columns; col += 2
){
int
nchars = columns[col + 1] columns[col] + 1;
/*
**
If
the input line
isn't
this long or the output
**
array
is
full,
we're done
*/
if(
columns[col]
>=
len
||
output_col
== MAX_INPUT
1
)
break;
/*
**
If
there
isn't
room
in the output array, only
copy
**
what
will
fit.
*/
if(
output_col
+
nchars
> MAX_INPUT
1)
nchars
= MAX_INPUT
output_col 1;
/*
Program 1.1 Rearrange characters continue.

资源文件列表:

Pointers on C.pdf.zip 大约有1个文件
  1. Pointers on C.pdf 7.09MB
0评论
提交 加载更多评论
其他资源 Python俄罗斯转盘
一个Python小白写的程序,可以用来整蛊好基友,内容包括无法关闭,禁用任务管理(可能会报毒),考虑到不少人没有Python环境,所以本人已将其打包为exe,另附源码给各位大佬参考学习,不喜勿喷,本资源完全免费,如果想要学习其中的原理,可以关注本人,会讲。谢谢。望过审。如果想要学习加数字签名请看https://blog.csdn.net/dounick/article/details/105643285(不是我的)
ad3-2.2.1-cp38-cp38-win-amd64.whl.zip
【ad3-2.2.1-cp38-cp38-win_amd64.whl.zip】此文件适用于Python3.8,Windows64位系统,请仔细核对版本 内含文件: 1. 如何安装whl文件.png【算是图文教程,一看就懂】 2. ad3-2.2.1-cp38-cp38-win_amd64.whl【安装需要用到的文件】 AD3 是一个用于求解大规模图形模型的软件包,特别是用于求解马尔可夫随机场(Markov Random Fields,MRFs)和条件随机场(Conditional Random Fields,CRFs)模型的推断问题。AD3 以其高效的算法和可扩展性而闻名,它被广泛应用于机器学习、自然语言处理、计算机视觉等领域。 AD3 主要用于解决以下问题: 1. 最大后验概率推断(MAP Inference):给定一个概率图模型,AD3 可以高效地找到最有可能的状态序列或配置,这在许多任务中都是非常重要的,比如分词、语义角色标注、语义分割等。 2. 边缘概率推断(Marginal Inference):通过 AD3,可以有效地计算给定观测条件下每个变量的边缘概率。 3. 参数估
Windows Research Kernel源码下载,构建无报错!免费!!
windows server2003 enterprice sp1 内核(不包括镜像),构建时用vs2022(2019也行)打开.sln文件即可,选择x86,win32,在点右边空心绿三角,即可编译(已包括编译好的文件),等到VS弹出“无法启动程序······”时,构建成功,进入 项目文件夹\base\ntos\build\exe\,编译成品为wrkx86.exe,正常情况下双击会报错。具体见https://blog.csdn.net/pycpp222/article/details/140438401?spm=1001.2014.3001.5501
Windows Research Kernel源码下载,构建无报错!免费!! Windows Research Kernel源码下载,构建无报错!免费!!
RKDevTool_Release_v2.96_zh.zip
RKDevTool_Release_v2.96_zh.zip
RKDevTool_Release_v2.96_zh.zip RKDevTool_Release_v2.96_zh.zip RKDevTool_Release_v2.96_zh.zip
机器人逆运动学下位机代码
机器人逆运动学下位机代码
自动化测试-Robotframework项目结构示例
代码执行需要按照根目录下的README.md中描述步骤执行
前端开发过程中的代码规范
通过几年的工作经验,和参考一些大厂规范以及一些开源的优秀源码,整理了一些前端代码规范,帮助我们后续可以写出更好维护的代码。
基于Java Web的传智书城项目-完整项目包
系统实现 4.1系统实现过程 4.1.1项目环境搭建 在开发功能模块之前,先进行项目环境及项目框架的搭建。 (1)确定项目开发环境 操作系统:Windows XP、Windows7或更高的Windows版本。Web 服务器:Tomcat 8.0。Java开发包:JDK1.8。数据库:MySQL8.0.33。开发工具:Eclipse Java EE IDE for Web Developers。浏览器:1E8.0或更高版本。 (2)创建数据库表 在MySQL数据库中创建一个名称为itcaststore的数据库,并根据表结构在itcaststore数据库中创建相应的表。 (3)创建项目,引入JAR包 在Eclipse 中创建一个名称为itcaststore的Dynamic WebProject,将项目所需JAR包导入到项目的WEB-INF/lib文件夹下。 本项目使用C3p0 数据源连接数据库,需要C3pO数据源的JAR包。项目的JSP页面使用了JSTL标签库,需要jstl.jar和standard.jar 两个包。项目中使用DBUtils工具处理数据的持久化操作。
基于Java Web的传智书城项目-完整项目包 基于Java Web的传智书城项目-完整项目包 基于Java Web的传智书城项目-完整项目包