answersLogoWhite

0


Best Answer

You can find in-depth information on how to use sscanf() in C file handling on crasseux.com/books/ctutorial/sscanf.html

One more useful website of learning basic of "C Programming" is cprogramming-bd.com

User Avatar

Wiki User

9y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

sscanf () function is a function that can be found in library. sscanf () will extract a string (or character array) and distribute the values to different variables. sscanf () will only stop scanning a value when it scanned spaces, new line, or a different datatype.

sscanf ([string], "[format specifiers]", ...[Variables where the values will be distributed]);

Example:

char strNew [99] = "Hello World 64";

char strHello [99];

char strWorld [99];

int num;

sscanf (strNew, " %s %s %d", strHello, strWorld, num);


With the example above, after the execution of the program, strHello's value would be "Hello"; strWorld's value would be "World" and num's value is 64.


If you only want a specific value in a string and you want to remove the other values, you can use asterisk (*) after the percent sign to stop scanning that value. In the example above, for example, I only need the number 64. Therefore:


sscanf (strNew, "%*s %*s %d", &num);

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you use sscanf() in C file handling?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you read input of a programme from a text file using borland c compiler from command prompt?

Use functions like fopen, fclose, fgets, sscanf, strtok


In what programming language is SSCANF a reference?

SSCANF is the Go Programming Language and originated from the C Programming Language. SSCANF is a function that reads data with specified format from a given stream source.


Why use pointer in c language with file handling?

Don't store pointers in files, it makes no sense.


What is difference between scanf and cin?

scanf is a function (available in C and C++)cin is an istream object (C++ only)Advice: when in doubt, use fgets+sscanf


You want a file handling c program?

yes


Decimal to binary conversion in c language?

sscanf, atoi, strtol, ...


Which function converts string into float?

in C: atof, strtod, sscanf


What is definition of file handling in c plus plus?

File is a place where information or data is stored. we make use of some of the file-handling functions in c like: fopen()-for opening a file. fclose()-to close a file. Every file being opened for any operations like: "r"- Read-Only mode. "w"-Write-only mode. "a"-append mode. "r+"-read+write mode. "w+"-write+read mode. "a+"-read+append mode. We should make use of FILE pointer ,in order to perform any such operations on the files. There are many input and output functions used along with files. fgetc() fgets() fscanf() fputc() fprintf() fputs() fseek() rewind() File handling is used to read or write a file without directly opening it.its contents are opened in another files by using above specified commands in c++ programming for file handling we have to use a header file but in c noheader file regarding to file handling is required


What is basic structure of file handling in c language?

open, read/write, close


How can a string be converted into a number in c?

With functions like sscanf, strtol, strtoul, atoi, atof etc.


What is file handling in c and c plus plus or objective c?

File handling is simply the process of opening, reading, writing and closing files. Files are simply streams for input and output, or the "serialisation" of objects. In other words, reading and writing data to and from disk storage.


You want C program on students information record using file handling?

yes sir