C Language Development Kit/Functions/Format2

From OptiWiki

Jump to: navigation, search
Description This function deletes all files on the specified drive.
Syntax
void format2(unsigned char drive);
Arguments
unsigned char drive
drive specifies the drive to format. The following constants are defined for this:
RAM_DISK The RAM disk
INTERNAL_DISK The internal SD card
DRIVE_A The RAM disk
DRIVE_C The internal SD card
Returns None
Remarks This function is almost identical to the format function, with one difference.

Where format uses the default drive, you should specify the drive with this function.

Example
#include <stdio.h>
#include <stdlib.h>
#include "lib.h"
 
void main( void )
{
    static char data[20+1];
    FILE *fp;
 
    while( 1 )
    {
        printf("\f1: mem = %lu", coreleft());
 
        if( NULL != ( fp = fopen("TEST.DAT", "wb")))
        {
            fwrite( data, 1, 20, fp);
            fclose(fp);
        }
 
        while( getchar() == EOF )
            idle();
 
        printf("\f2: mem = %lu", coreleft());
        format();
        while( getchar() == EOF )
            idle();
 
        printf("\f3: mem = %lu", coreleft());
        while( getchar() == EOF )
            idle();
    }
}


Views
Personal tools