In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "C language file application example analysis". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "c language file application case analysis" bar!
Topic description:
In a given program, the function of fun is to write the strings, integers and floating point numbers given by parameters into the text file, then read them one by one from the text file by string mode, and call the library functions atoi and atof to convert the string into corresponding integers and floating point numbers, and then display them on the screen.
Please fill in the correct content at the underline of the program and delete the underline so that the program can get the correct result.
Note: the source program is stored in BLANK1.C under the examinee's folder.
Do not add or delete lines, nor change the structure of the program!
Code part:
# include
# include
Void fun (char * s, int a, double f)
{
/ * found*/
_ _ 1__ fp
Char str [100], str1 [100], str2 [100]
Int A1; double F1
Fp = fopen ("file1.txt", "w")
Fprintf (fp, "% s% d% f\ n", s, a, f)
/ * found*/
_ _ 2__
Fp = fopen ("file1.txt", "r")
/ * found*/
Fscanf (_ _ 3clients, "% s%s%s", str, str1, str2)
Fclose (fp)
A1 = atoi (str1)
F1 = atof (str2)
Printf ("\ nThe result:\ n\ n% s% d% f\ n", str, A1, F1)
}
Main ()
{char a [10] = "Hello!"; int baked 12345
Double c = 98.76
Fun (a _
Getchar ()
}
Reference answer:
1. FILE *
2. Fclose (fp)
3 、 fp
The examination point of this question is the application of file function.
In the fun function, the file pointer variable is defined first, so the first blank is filled with: FILE *; in the fun function, the text file is opened by creation, then the formatted data is written into the streaming file, and then the text file is opened as read-only, and the characters in the file are output to the screen, so the file is closed, so the second fill in: fclose (fp) The input data format is fscanf (file pointer, format control string, input item table) through the fscanf function, so fill in the third place: fp.
At this point, I believe you have a deeper understanding of "C language file application example analysis". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.