当前位置:网站首页>C final review
C final review
2022-07-05 18:32:00 【mxrone】
1. Direct access is to access directly by using the address of the variable .(T)
analysis :
(1) Direct access :
Access the variable value according to the address of the variable .
(2) Indirect access to :
Access variables through variables that store variable addresses .
2. Let the variable be defined as int a[2]={1,3}, *p=&a[0]+1;
be *p
The value of is ( 3 ).
analysis : Notice the address plus one , instead of It's worth adding 1;
3. For the following structure definitions ,++p->str
Medium ++
Add to (A).
struct {
int len;
char *str;
} *p;
A. The pointer str
On B. The pointer p
On C.str
Point to the content D. Grammar mistakes
4.C Structure type variables in the language during program execution ( All members always reside in memory ).
5. What linked lists don't have is ( Any element can be accessed at random ).
6. When using linked list instead of array for data operation , Query is more convenient .(F)
analysis :
Array : Support random access , Easy to use , Query efficiency is higher than linked list , Memory It is a continuous area .
Linked list : No data access , Can be dynamically added or deleted Variable size , Memory may be discontinuous , Chain store , Query efficiency is low .
7. stay C In the program , Functions can be either nested or defined , You can also nest calls .(F)
analysis :
C The definitions of functions in language are parallel to each other 、 Mutually independent , That is to say, when defining a function , A function body cannot contain the definition of another function , That is, functions cannot be nested , But you can nest calls .
8. The file pointer points to the access location of the file data in the file buffer .(F)
analysis :
The file pointer points to A memory area , This area stores information about the open file , Including the current position of the file reading pointer 、 File read buffer size and other information , Not pointing to a file .
9. Using a structure pointer as a function parameter only needs to pass an address value , therefore , It can improve the efficiency of parameter transmission .(T)
10. Known and defined ,FILE fp; char str[] = "Good!"; fp = fopen("filename.dat", "wb");
Will array str The string stored in is written to the name filename.dat In the binary file of . The required statement is ( D).
A.fwrite(str[0], sizeof(char), 1, fp) B.fread(str, sizeof(char), 5, fp)
C.fwrite(fp, sizeof(char), 5, str) D.fwrite(str, sizeof(char), 5, fp)
analysis :
fread And fwrite function
The function prototype :
size_t fread(void *buffer, size_t size, size_t, count, FILE *pf)
size_t fwrite(void *buffer, size_t size, size_t count, FILE *pf)
fread and fwrite Function is generally used for input and output of binary files .
fscanf And fprintf function
for example :
fscanf(fp, "%s %d %d %f\n", pb->name, &pb->num, &pb->age, &pb->score)
fprintf(fp,"%s %d %d %f\n", pa->name, pa->num, pa->age, pa->score)
fscanf The function :
Press “ Format string ” Specified format , from “ File type pointer ” Read data from the current location of the file pointed to , Then press “ Entry address table column ” The order of , Store the read data into the specified memory unit .
fprintf The function :
Press “ Format string ” Specified format , take “ Output item table column ” Write the values of the items specified in “ File type pointer ” The current location of the file pointed to . If the write is successful ,fprintf The return value of the function is the number of characters written to the file ( Or number of bytes ), Otherwise return to EOF(-1).
11. Open a text file for student.txt, The correct way to add data is ( B ).
A.fp=fopen("my.txt","r") B.fp=fopen("my.txt","a")
C.fp=fopen("my.txt","w") D.fp=fopen("my.txt","w+")
r With read-only Way to open a file . The pointer to the file will be placed at the beginning of the file . This is the default mode .
a Open a file for Additional . If the file already exists , The file pointer will be placed at the end of the file . in other words , The new content will be written after the existing content . If the file does not exist , Create a new file to write to .
a+ Open a file For reading and writing only . If the file already exists , The file pointer will be placed at the end of the file . Append mode when the file opens . If the file does not exist , Create a new file for reading and writing .
w Open a file Write only . Open the file if it already exists , And edit from the beginning , The original content will be deleted . If the file does not exist , Create a new file .
w+ Open a file for Reading and writing . Open the file if it already exists , And edit from the beginning , The original content will be deleted . If the file does not exist , Create a new file .
wb With Binary format Open a file Write only . Open the file if it already exists , And edit from the beginning , The original content will be deleted . If the file does not exist , Create a new file . Generally used for non - text files such as pictures .
wb+ With Binary format Open a file For reading and writing . Open the file if it already exists , And edit from the beginning , The original content will be deleted . If the file does not exist , Create a new file . Generally used for non - text files such as pictures .
12.
The following description is wrong ( D ).
A. Function calls can appear in an expression B. Function calls can appear in the execution statement
C. Function calls can be used as arguments to a function D. Function calls can be used as formal parameters of a function
analysis :
The return value is stored in the register , No address , It cannot be a formal parameter , But it can be used as an argument .
边栏推荐
- Crontab 日志:如何记录我的 Cron 脚本的输出
- 《ClickHouse原理解析与应用实践》读书笔记(5)
- buuctf-pwn write-ups (9)
- The 11th China cloud computing standards and Applications Conference | cloud computing national standards and white paper series release, and Huayun data fully participated in the preparation
- sample_rate(采樣率),sample(采樣),duration(時長)是什麼關系
- Record a case of using WinDbg to analyze memory "leakage"
- RPC protocol details
- Check namespaces and classes
- 常见时间复杂度
- The origin of PTS, DTS and duration of audio and video packages
猜你喜欢
Various pits of vs2017 QT
FCN: Fully Convolutional Networks for Semantic Segmentation
Take a look at semaphore, the current limiting tool provided by JUC
《力扣刷题计划》复制带随机指针的链表
第十一届中国云计算标准和应用大会 | 云计算国家标准及白皮书系列发布 华云数据全面参与编制
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
怎么自动安装pythn三方库
Find the first k small element select_ k
FCN: Fully Convolutional Networks for Semantic Segmentation
Vulnhub's darkhole_ two
随机推荐
Share: ZTE Yuanhang 30 Pro root unlock BL magick ZTE 7532n 8040n 9041n brush mask original brush package root method Download
Reading notes of Clickhouse principle analysis and Application Practice (5)
分享:中兴 远航 30 pro root 解锁BL magisk ZTE 7532N 8040N 9041N 刷机 刷面具原厂刷机包 root方法下载
Is it safe to make fund fixed investment on access letter?
Wu Enda team 2022 machine learning course, coming
IDEA配置npm启动
项目中遇到的问题 u-parse 组件渲染问题
Problems encountered in the project u-parse component rendering problems
How to improve the thermal management in PCB design with the effective placement of thermal through holes?
English sentence pattern reference
金太阳开户安全吗?万一免5开户能办理吗?
Maximum artificial island [how to make all nodes of a connected component record the total number of nodes? + number the connected component]
Simulate the hundred prisoner problem
The 10th global Cloud Computing Conference | Huayun data won the "special contribution award for the 10th anniversary of 2013-2022"
@Extension, @spi annotation principle
New words new words new words new words [2]
[paddlepaddle] paddedetection face recognition custom data set
Is it safe for Apple mobile phone to speculate in stocks? Is it a fraud to get new debts?
[PM2 details]
Matlab built-in function how different colors, matlab subsection function different colors drawing