I'm new to FILE I/O Stream and I want to write a program, which converts chars (read from "texti.txt") like "ä,Ä,ü,Ü,ö,Ö" to "ae,Ae,ue,Ue,oe,Oe" and write them in a new file called "texto.txt".
First Question: Is it ok to have two file pointers (on to each file) at the same time like i do?
Second Question: What am I doing wrong with character compare in the switch statement? VS2015 is warning that cases 2 and 3 already exist (reference to case 1)
Thirt Question
Does fpo
(file pointer to output-file) increment itself automatically by writig a char?
Question four: VS2015 is warning:
C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Is there another function I should use?
int main()
{
char c;
FILE *fpi;
FILE *fpo;
fpi = fopen("texti.txt","r");
fpo = fopen("texto.txt", "w");
if (fpi == NULL)
fprintf(stderr, "Fehler beim Lesen");
while (!feof(fpi))
{
c = fgetc(fpi);
switch (c)
{
case 'ä'||'Ä':
fputc('a', fpo);
fputc('e', fpo);
break;
case 'ö'||'Ö':
fputc('o', fpo);
fputc('e', fpo);
break;
case 'ü' || 'Ü':
fputc('u', fpo);
fputc('e', fpo);
break;
default:
fputc((c), fpo);
}
fpi++;
}
fclose(fpi);
fclose(fpo);
}