#include <stdio.h>
#include <stdlib.h>
int main( void )
{
FILE *ptr;
ptr = fopen( "text1.txt", "w+");
if( ptr == NULL )
{
perror( "File:" );
exit(1);
}
fprintf(ptr,"100\n200\n300" );
fclose( ptr );
return 0;
}
/*************/
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
FILE *ptr;
int a,b,c;
ptr = fopen( "text1.txt", "r");
if( ptr == NULL )
{
perror( "File:" );
exit(1);
}
fscanf(ptr,"%d\n%d\n%d", &a,&b,&c );
fclose( ptr );
printf("total is %d", a+b+c );
return 0;
}