Jak poprawić ten kod?
Pozdrawiam i dzięki z góry!
Kod: Zaznacz cały
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
FILE *fp;
void Func_e() //Save matrices to the file
{
int i;
char name[20];
int are_there_illegal_characters;
//choose the file name
printf("\n*** Choose the file name (0 for exit) ***");
printf("\nYour choice: ");
do
{
fflush(stdin);
scanf("%s",&name);
are_there_illegal_characters = 0; //check whether there are any illegal characters
for (i=0;i<20;i++)
{
if (name[i] == '6') are_there_illegal_characters = 1;
}
if (are_there_illegal_characters == 0)
{printf("OK!");break;}
else
{
if (name=='0')
{printf("You have not chosen the file name.");break;}
else
{printf("Your choice is unproper. You cannot use number 6 in your file name.");}
}
} while (1==1);
fp = fopen(name,"a");
fclose(fp);
}
int main(int argc, char *argv[])
{
Func_e();
}
Jak poprawić ten kod?
Pozdrawiam i dzięki z góry!