This C programming code is not run properly. Please fix this problem and solve this error. # include # include int main( ) { // Declare the file pointer FILE *filePointer,*filePointer1 ; int n; printf("enter a key for encryption"); scanf("%d",&n); // Declare the variable for the data to be read from file char dataToBeRead[50]; filePointer = fopen("test.txt", "r") ; filePointer1 = fopen("final.txt", "w") ; // Check if this filePointer is null // which maybe if the file does not exist if ( filePointer == NULL ) { printf( "test.txt file failed to open." ) ; } else { printf("The file is now opened.\n") ; // Read the dataToBeRead from the file // using fgets() method while( fgets ( dataToBeRead, 50, filePointer ) != NULL ) { // Print the dataToBeRead printf( "%s" , dataToBeRead ) ; int i; for(i=0;i
This C programming code is not run properly. Please fix this problem and solve this error.
# include <stdio.h>
# include <string.h>
int main( )
{
// Declare the file pointer
FILE *filePointer,*filePointer1 ;
int n;
printf("enter a key for encryption");
scanf("%d",&n);
// Declare the variable for the data to be read from file
char dataToBeRead[50];
filePointer = fopen("test.txt", "r") ;
filePointer1 = fopen("final.txt", "w") ;
// Check if this filePointer is null
// which maybe if the file does not exist
if ( filePointer == NULL )
{
printf( "test.txt file failed to open." ) ;
}
else
{
printf("The file is now opened.\n") ;
// Read the dataToBeRead from the file
// using fgets() method
while( fgets ( dataToBeRead, 50, filePointer ) != NULL )
{
// Print the dataToBeRead
printf( "%s" , dataToBeRead ) ;
int i;
for(i=0;i<strlen(dataToBeRead);i++)
dataToBeRead[i]=(dataToBeRead[i]+n)%26;
fputs(dataToBeWritten, filePointer1) ;
fputs("\n", filePointer1) ;
}
// Closing the file using fclose()
fclose(filePointer) ;
printf("Data successfully read from file GfgTest.c\n");
printf("The file is now closed.") ;
}
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)