当前位置:网站首页>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 .
边栏推荐
- U-Net: Convolutional Networks for Biomedical Images Segmentation
- Reptile 01 basic principles of reptile
- rust统计文件中单词出现的次数
- Find the first k small element select_ k
- Introduction to Resampling
- Generate classes from XML schema
- [PM2 details]
- FCN: Fully Convolutional Networks for Semantic Segmentation
- jdbc读大量数据导致内存溢出
- Sibling components carry out value transfer (there is a sequence displayed)
猜你喜欢

如何获取飞机穿过雷达两端的坐标

Find the first k small element select_ k

Simulate the hundred prisoner problem

ConvMAE(2022-05)
![Whether to take a duplicate subset with duplicate elements [how to take a subset? How to remove duplicates?]](/img/b2/d019c3f0b85a6c0d334a092fa6c23c.png)
Whether to take a duplicate subset with duplicate elements [how to take a subset? How to remove duplicates?]

Failed to virtualize table with JMeter

第十一届中国云计算标准和应用大会 | 华云数据成为全国信标委云计算标准工作组云迁移专题组副组长单位副组长单位

彻底理解为什么网络 I/O 会被阻塞?

Record eval() and no in pytoch_ grad()

About Estimation with Cross-Validation
随机推荐
Use JMeter to record scripts and debug
开户注册挖财安全吗?有没有风险的?靠谱吗?
vulnhub之darkhole_2
Cronab log: how to record the output of my cron script
RPC protocol details
Thoroughly understand why network i/o is blocked?
Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app
Simulate the hundred prisoner problem
怎么自动安装pythn三方库
How to obtain the coordinates of the aircraft passing through both ends of the radar
【在優麒麟上使用Electron開發桌面應】
第十一届中国云计算标准和应用大会 | 云计算国家标准及白皮书系列发布 华云数据全面参与编制
lombok @Builder注解
Share: ZTE Yuanhang 30 Pro root unlock BL magick ZTE 7532n 8040n 9041n brush mask original brush package root method Download
关于服装ERP,你想知道的都在这里了
Take a look at semaphore, the current limiting tool provided by JUC
[PM2 details]
How to automatically install pythn third-party libraries
node_exporter内存使用率不显示
兄弟组件进行传值(显示有先后顺序)