SW006014 Microchip Technology, SW006014 Datasheet - Page 67

C COMPILER MPLAB FOR PIC24 MCU

SW006014

Manufacturer Part Number
SW006014
Description
C COMPILER MPLAB FOR PIC24 MCU
Manufacturer
Microchip Technology
Type
MPLAB® C Compilerr
Series
PIC24r
Datasheet

Specifications of SW006014

Supported Families
PIC24
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24
Tool Function
Compiler
Tool Type
Compiler
Processor Series
PIC24
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC24
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
fscanf (Continued)
Prototype:
Arguments:
Return Value:
Remarks:
Example:
int fscanf(FILE *stream, const char *format, ...);
stream
format
...
Returns the number of items successfully converted and assigned. If
no items are assigned, a 0 is returned. EOF is returned if end-of-file is
encountered before the first conversion or if an error occurs.
The format argument has the same syntax and use that it has in
scanf.
#include <stdio.h> /* for fopen, fscanf,
int main(void)
{
}
Input:
Contents of afile:
Print this string 100 times
Output:
Print
this
string
100
times
FILE *myfile;
char s[30];
int x;
char a;
if ((myfile = fopen("afile", "w+")) == NULL)
else
{
}
printf("Cannot open afile\n");
fprintf(myfile, "%s %d times%c",
fseek(myfile, 0L, SEEK_SET);
fscanf(myfile, "%s", s);
printf("%s\n", s);
fscanf(myfile, "%s", s);
printf("%s\n", s);
fscanf(myfile, "%s", s);
printf("%s\n", s);
fscanf(myfile, "%d", &x);
printf("%d\n", x);
fscanf(myfile, "%s", s);
printf("%s\n", s);
fscanf(myfile, "%c", a);
printf("%c\n", a);
fclose(myfile);
pointer to the open stream from which to read data
format control string
optional arguments
"Print this string", 100, '\n');
/* fclose, fprintf,
/* fseek, printf, FILE, */
/* NULL, SEEK_SET
DS51456E-page 63
*/
*/
*/

Related parts for SW006014