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系統程式設計 第二版
86
|
第三章
fwrite()
可將引數
buf
所指向的資料寫入引數
stream
所指向的串流,所寫入的位元組數
目由
size*nr
來決定(資料中共有
nr
個元素,每個元素具有
size
個位元組)。檔案指標
會前進到實際所寫入的位元組數目。
執行成功時,
fwrite()
會傳回所寫入的元素數目(而不是位元組數目!)。執行失敗
時,則會透過傳回一個小於
nr
的值,指出發生了錯誤。
使用緩衝式
I/O
的簡單程式
現在讓我們來看一個例子—事實上,這是一個完整的程式—它整合進了本章迄今為止所
介紹的許多介面。此程式首先會定義
struct pirate
,接著以該型別宣告兩個變數。此
程式會初始設定其中一個變數,隨後把它寫入磁碟(也就是,經由輸出串流寫入檔案
data
)。然後此程式會經由不同的串流從
data
檔案把資料直接讀回
struct pirate
的另一
個實例(
instance
)。最後,此程式會把該結構的內容寫入標準輸出:
#include <stdio.h>
int main (void)
{
FILE *in, *out;
struct pirate {
char name[100]; /*
真實姓名
*/
unsigned long booty; /*
以英鎊為單位
*/
unsigned int beard_len; /*
以英吋為單位
*/
} p, blackbeard = { "Edward Teach", 950, 48 };
out = fopen ("data", "w");
if (!out) { ...
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