Acceptable Solution? 
Author Message
 Acceptable Solution?

Gaia dhuit,


Quote:
>Hi People,

>I previously posted a question on how to delete records and have come up with the
>solution below.
>  Is this acceptable?

What does "acceptable" mean ?

To me ?

Sure it's acceptable today, but I just scanned your code, didn't look
at it in detail. And tomorrow I might be cranky and not accept it.

To comp.lang.c ?

Shall we take a vote ?

To the compiler ?

Presumably (again I only scanned the code, but seems ok)

To you ?

To the pope ?

---
Janus

http://www.*-*-*.com/ ~jab

Gaia leat



Sat, 24 Apr 1999 03:00:00 GMT  
 Acceptable Solution?

Hi People,

I previously posted a question on how to delete records and have come up with the
solution below. The solution assigns a null value to the book no. field.

However, the record will still remain physically in the file but will not be made
visible to the user in the read file. The read file will only display book numbers that
are more than 0.  Is this acceptable?

Thanks for your time.

#include <stdio.h>

main()
{
 int num;
 int x;
 char ans = 'y';
 char cont = 'y';
 FILE *fp; char bk[3];
 fp = fopen("c:book.dat","rb");
 {
  struct book
  {
   int  book_no;
   char book_title[50];
  };

  struct book bk[3];
  int *ptr;
  while (cont == 'y')
   {clrscr();
    printf("Which book to delete? " );
    scanf("%d", &num);
    fread(bk,sizeof(struct book),3,fp);
    for (x=0; x<3; x++)
       {if (bk[x].book_no == num)
          {printf("Book No: %d\n", bk[x].book_no);
           printf("Book Title: %s\n",bk[x].book_title);
           fp = fopen("c:book.dat","wb");
           printf("Delete Y/N?");
           fflush(stdin);
           scanf("%c",&ans);
           if (ans == 'y')
               {bk[x].book_no = '\0';
                fwrite(bk,sizeof(struct book),3,fp);}}
       }
    printf("Continue Y/N?");
    fflush(stdin);
    scanf("%c",&cont);
    fclose(fp);
   }
 }

Quote:
}



Sat, 24 Apr 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. In VS.NET: May a solution contain other solutions

2. are these lines acceptable ANSI C ?

3. C keywords, delimiters and acceptable characters

4. The limits of "acceptable" code

5. How: Create acceptable argv[] for execv() from string?

6. Teaching Worldwide More Acceptable Language

7. are these lines acceptable ANSI C ?

8. vb acceptable event interface

9. vb acceptable event interface

10. Is this acceptable coding practice ?

11. ANN: TwinText 1.3 Released - Source Code Documentation Solution

12. Project Configurations are out of date -- another solution for Libraries/LIB files

 

 
Powered by phpBB® Forum Software