Cant compile the program in Pelles C only in DEV+ It reports error with "gets" wants to call it _getch but it still wont run. then it wasnts a Go switch but does not show how to use it. how would this simple program be worded so it runs? in Pelles C _Thank you.
// demonstrates opening files//
#include<conio.h>
#include<stdio.h>
int main()
{
FILE *fp; // pointer to point to our file we want to open//
char ch, filename[40], mode[4]; // initialize variables ch, filenane and mode//
while(1) // do forever//
{
// input the file name we want opened//
printf("\n Enter the file name to open: ");
gets(filename);
printf("\nEnter the mode to use on the file (Max 3 cgaracters): ");// r,w,a r+,w+ a+//
gets(mode);
// try to open the file//
if ( (fp = fopen( filename, mode)) != NULL )
{
printf("\n Successful opening %s in mode %s.\n",
filename, mode);
fclose(fp);
puts("Enter x to exit or any other key to continue.");
if ((ch = getchar()) == 'x')
break;
else
continue;
}
else
{
fprintf( stderr,"\nError opening file %s in mode %s.", filename, mode);
puts("\nEnter x to exit or any othr key to try again: ");
if ((ch = getchar()) == 'x')
break;
else
continue;
}
}
}