Advertisement
FILE *fopen(const char *filename, const char *mode)
File Mode | Description |
---|---|
"r+" | Searches for the file and opens the file(if the file is found). If the file is not found, NULL is returned and no new file is created. Allows you to read, write and modify the content of file.. |
Hello, how are you going? Have a pleasant day ahead!
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
/* This will look the file in the directory where this C program file is stored */
FILE *frplus = fopen("File2.txt", "r+"); /* Opens the file for reading/writing/modification */
char ch;
/* If the searched file is not found, the program exits */
if(frplus==NULL)
{
printf("can not open target file\n");
exit(1);
}
/* If the file is found */
while(1)
{
ch = fgetc(frplus);
if(ch=='Z')
{
printf("%c", ch);
fseek(frplus, -1, SEEK_CUR);
fputc('e', frplus);
fseek(frplus, 0, SEEK_CUR);
}
if(ch == EOF)
break;
}
fclose(frplus);
return 0;
}
H1llo, how ar1 you going? Hav1 a pl1asant day ah1ad!
Advertisement
int fseek(FILE * file, long int offset, int source)
Macros | Description |
---|---|
SEEK_SET | Beginning of file |
SEEK_CUR | Current position in the file |
SEEK_END | End of file |
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement