Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <stdio.h>
- int main( )
- {
- FILE *filePointer,*fo ;
- int n;
- filePointer = fopen("input.txt", "r") ;
- fo=fopen("output.txt","w");
- if ( filePointer == NULL )
- {
- printf( "Failed to open \n" ) ;
- }
- else
- {
- printf("The file is now opened.\n") ;
- fscanf(filePointer,"%d",&n);
- int arr[n],i=0;
- fscanf(filePointer,"%d",&n);
- while(fscanf(filePointer,"%d",&arr[i])!=EOF){
- i++;
- }
- for(int i=0;i<n;i++){
- fprintf(fo,"%d ",arr[i]);
- }
- fclose(filePointer) ;
- fclose(fo);
- printf("The file is now closed.") ;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment