SW006013 Microchip Technology, SW006013 Datasheet - Page 59

MPLAB C Compiler For DsPIC DSCs

SW006013

Manufacturer Part Number
SW006013
Description
MPLAB C Compiler For DsPIC DSCs
Manufacturer
Microchip Technology
Series
DsPIC30F/33Fr
Type
MPLAB® C Compilerr
Datasheet

Specifications of SW006013

Supported Families
DsPIC30F, DsPIC33F
Core Architecture
DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
DsPIC30F And DsPIC33F
Tool Function
Compiler
Tool Type
Compiler
Processor Series
dsPIC
Lead Free Status / RoHS Status
na
For Use With/related Products
dSPIC DSCs
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2008 Microchip Technology Inc.
fgets
Description:
Include:
Prototype:
Arguments:
Return Value:
Remarks:
Example:
Get a string from a stream
<stdio.h>
char *fgets(char *s, int n, FILE *stream);
s
n
stream
Returns a pointer to the string s if successful; otherwise, returns a null
pointer
The function reads characters from the input stream and stores them
into the string pointed to by s until it has read n-1 characters, stores a
newline character or sets the end-of-file or error indicators. If any char-
acters were stored, a null character is stored immediately after the last
read character in the next element of the array. If fgets sets the error
indicator, the array contents are indeterminate.
#include <stdio.h> /* for fgets, printf, */
#define MAX 50
int main(void)
{
}
Input:
Contents of afile.txt (used as input):
Short
Longer string
Output:
Short
|Longer string
|
FILE *buf;
char s[MAX];
if ((buf = fopen("afile.txt", "r")) == NULL)
else
{
}
printf("Cannot open afile.txt\n");
while (fgets(s, MAX, buf) != NULL)
{
}
fclose(buf);
printf("%s|", s);
pointer to the storage string
maximum number of characters to read
pointer to the open stream.
/* fopen, fclose,
/* FILE, NULL
DS51456E-page 55
*/
*/

Related parts for SW006013