Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
緩衝式
I/O
|
81
#include <stdio.h>
int ungetc (int c, FILE *stream);
叫用此函式就可以把
c
(會被轉型成
unsigned char
)推回
stream
。執行成功時,會傳回
c
;執行失敗時,則會傳回
EOF
。隨後讀取
stream
將會傳回
c
。如果有多個字符被推回,
則它們會以相反的順序(後進先出,如同一個堆疊)被傳回—也就是,最後被推回的字
符,會首先被傳回。
C
標準規定只有一個推回操作可以保證執行成功,而不會干擾到讀
取要求。有些實作,只允許單個推回操作;
Linux
則允許無限多個推回操作,只要有記
憶體可供使用。當然,單個推回操作總是會執行成功。
叫用
ungetc()
之後,如果在發出讀取要求之前,叫用了一個查找函式(見第
3
章〈查找
一個串流〉一節),將使得被推回的所有字符遭到丟棄。此狀況會出現在一個行程的各
執行緒之間,由於這些執行緒會共用緩衝區。
讀取一整列
函式
fgets()
可用於從所指定的串流讀取一個字串:
#include <stdio.h>
char * fgets (char *str, int size, FILE *stream);
此函式會從
stream
讀取
size-1
個位元組,並把結果存入
str
。讀進最後一個位元組後,
緩衝區會被存入一個
null
字符(
\0
)。讀到一個
EOF
或一個
newline
(換列)字符後,便
會停止讀取的動作。若讀到一個
newline
字符,則
\n
會被存入
str
。
執行成功時,會傳回
str
;執行失敗時,則傳回 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
優雅的SciPy|Python科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812