Usage of fscanf function
In the past, when parsing regular files, I either used regular expressions, or stupidly wrote my own program to parse regular files. Today I suddenly discovered that there is a ready-made function in the c library function that can parse regular files, which is the fscanf() function.
C language video tutorial)
fscanf() function (a bit like a regular expression): Function: Perform formatted input from a stream, fscanf ends when it encounters a space or a newline. Note that it also ends when it encounters a space. Usage: int fscanf(FILE *stream, char *format,[argument...]);int fscanf(file pointer, format string, input list);Return value: integer, returns the number of parameters read successfully, and returns EOF(-1) on failure.
Example 1:
#include <stdlib.h> #include <stdio.h> int main(void) { int i; printf("Input an integer:"); /*从标准输入中读取一个整数*/ if(fscanf(stdin, "%d",&i)) printf("The integer read was:%d\n", i); else { fprintf(stderr, "Error reading an integer from stdin.\n"); exit(1); } return 0; } 返回EOF如果读取到文件结尾。
The above is the detailed content of Usage of fscanf function. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

This error is usually caused by hardware problems in the storage device and can be solved by checking connections, scanning with CHKDSK, updating drivers, detecting hard disk health, and adjusting disk policies. 1. Check whether the hard disk connection is normal. External hard disk can be replaced with cables or interfaces. The internal hard disk needs to be restarted and plugged and confirmed to be recognized by BIOS; 2. Run the chkdskX:/f/r command as an administrator to scan and repair disk errors, and execute after restart; 3. Update or reinstall the hard disk driver through the device manager; 4. Use CrystalDiskInfo to view the SMART status. If there is a bad channel warning, immediately backup the data and replace the hard disk; 5. Modify the disk strategy for external hard disks to "better performance" or "quickly delete". If the above steps are invalid,

Tohideyourphonenumberwhenmakingacall,useoneofthesemethods:1.Dial67beforethenumberforatemporaryblock,whichworksonmostphonesandcarriersbutnotwithtoll-freeoremergencynumbers.2.ContactyourcarriertopermanentlyblockyourcallerID,anduse82beforeanumbertounblo

TheissueiscausedbytheFAT32filesystem,whichlimitsindividualfilestounder4GB;2.CheckyourUdisk’sformatviaFileExploreronWindowsorDiskUtilityonMac;3.ReformatthedrivetoexFATforcross-platformcompatibilityandlargefilesupport,orNTFSforWindows-onlyuse,afterback

CheckfordebrisintheheadphonejackorUSB-Cportandcleanit,asadirtyportcancausethephoneto误detectaccessoriesandswitchtospeaker.2.Reviewaccessibilitysettings—onAndroid,gotoSettings>Accessibility>Hearing;oniPhone,gotoSettings>Accessibility>CallAu

The "0xc000007b" error is usually caused by system environment problems. The solutions are as follows: 1. Update or reinstall the graphics card driver, especially after replacing the graphics card or reinstalling the system; 2. Install or repair the Microsoft VisualC Redistributable package, it is recommended to install both x86 and x64 versions; 3. Run the system file checker (SFC) and DISM commands to repair the system files; 4. Check the program compatibility to match 32/64 bits, try to run as an administrator or set the compatibility mode.

EnsureBluetoothisenabledviaActionCenterandSettings,checkingforphysicalswitchesorfunctionkeysifnotvisible.2.Runthebuilt-inBluetoothtroubleshooterinSettingstoautomaticallyfixcommonissues.3.UpdatetheBluetoothdriverthroughDeviceManager,oruninstallandrein

Donotdouble-clickanunexpected.lnkfileonaUSBstick,asitmayexecutemalware.2.Right-clickthefileandcheckitsProperties,especiallytheTargetfield,toseeifitpointstoasuspiciousexecutableorscript.3.EnableviewingofhiddenfilesviaFileExplorerandFolderOptionstoreve

Mappednetworkdrivesnotconnectingcanbefixedbyfollowingthesesteps:1.Verifynetworkandshareaccessbyensuringthedeviceisonthesamenetwork,testingthepathviaRun(\\IPor\\ComputerName),confirmingfilesharingisenabled,andcheckingfirewallsettingsblockSMB(port4