🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #735

Re: General protection exception?

#735
From: Martin Ambuhl
Date: Wed, 02 Dec 1998 00:00
59 lines
3501 bytes
Mark Hayward wrote:

[A Massive cross-posting]
It is extremely rude to spew all over usenet just because you are too
lazy to find the right newsgroup.  Accepted usenet practice is
1) to lurk in a newsgroup for at least a week before posting
2) to read the FAQs for newsgroups before posting.
This vomiting at random over usenet indicates you have done neither.
I have set the followups to alt.comp.lang.learn.c-c++ only.

> 
> Hi,
> I'm learning C (Not C++ yet) and I'm having some trouble with a function.
> I'm using Borland Turbo C++ 4.5. Basically it's part of a database program
> which stores details about computers. The function  is meant to save each
> individual record as a seperate file called "rec[record number goes in
> here]". 

This must be one of the worst ideas I have ever seen for a database. 
Rethink how you might store your records in a single file.

>I found that I couldn't increment the number in the filename
> directly, by doing something similar to:
> for(y=0; y<ctr; y++)
> {
>     *filename="rec%d",y;
>     fopen(filename);
>     /*Save data operations here*/
> }

This is grossly illegal.  On the assumption that you have properly
declared filename and some fileptr, such as
    char filename[FILENAME_MAX];
    FILE *outfile;

and have #included <stdio.h>
   for (y = 0; y < ctr; y++)
   {
       sprintf(filename,"rec%d",y);
       if (!(outfile = fopen(filename,"w"))) 
       { /* hand open error */ }
       /* file operations */
       fclose(outfile);
    }

Please start your study by reading a decent text.  Programming is a
discipline in which guessing at the language is rarely rewarded.

> Please e-mail all replies.

This is extremely rude.  Because it is clear that you treat usenet as a
write-only medium and have no respect for anyone else, I have e-mailed
this, but mend your ways.  It is not in your interests to become known
as an anti-social moron.


-- 
Martin Ambuhl (mambuhl@earthlink.net)
Note: mambuhl@tiac.net will soon be inactive
Technical Details
Message-ID: <3665BE59.DFE89263@earthlink.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7447iu$ldg$1@newnews.global.net.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f79ee,8329580fde881798
X-Google-Attributes: gidf79ee,public
X-Google-Thread: 10caf2,8329580fde881798
X-Google-Attributes: gid10caf2,public
X-Google-Thread: 109fba,8329580fde881798
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10c73c,8329580fde881798
X-Google-Attributes: gid10c73c,public
X-Google-Thread: 107276,8329580fde881798
X-Google-Attributes: gid107276,public
X-Google-Thread: 1122df,8329580fde881798
X-Google-Attributes: gid1122df,public
X-Google-Thread: 114592,8329580fde881798
X-Google-Attributes: gid114592,public
X-Google-Thread: 1158f7,8329580fde881798
X-Google-Attributes: gid1158f7,public
From: Martin Ambuhl <mambuhl@earthlink.net>
Subject: Re: General protection exception?
Date: 1998/12/02
Message-ID: <3665BE59.DFE89263@earthlink.net>
X-Deja-AN: 418007587
Content-Transfer-Encoding: 7bit
References: <7447iu$ldg$1@newnews.global.net.uk>
To: Mark Hayward <mhayward@globalnet.co.uk>
X-Accept-Language: en
X-Posted-Path-Was: not-for-mail
Followup-To: alt.comp.lang.learn.c-c++
Content-Type: text/plain; charset=us-ascii
X-ELN-Date: 2 Dec 1998 22:27:51 GMT
X-ELN-Insert-Date: Wed Dec  2 14:35:36 1998
Organization: Nocturnal Aviation
Mime-Version: 1.0
Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c++,de.comp.lang.c++,fj.lang.c++,it.comp.lang.c++,relcom.fido.su.c-c++,relcom.fido.su.c-c++.visualage,sdsu.c++,utexas.class.cs105.c++