Shows the function of fwrite and memset
Code: -
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NUM 8192
#define TIM 50
int main(void)
{
    char *obuf = NULL;
    FILE *stream = NULL;
    int i, len;
    stream = fopen("top", "wb");
    obuf = malloc(NUM);
    memset(obuf, 'a', NUM);
    for (i = 0; i < TIM; ++i) {
       len = fwrite(obuf, 1, NUM, stream);
       printf("single, %d\n", len);
    }
    fclose(stream);
    return 0;
}
Pradyut 
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
 
 
No comments:
Post a Comment