🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: FILE READ PROBLEM

#649
From: Philip Tillsley
Date: Sat, 15 Nov 1997 00:00
64 lines
2883 bytes
GREG HOOPER wrote:
> 
> Below is a program that achieves the correct end result that I'm after. The
> problem is
> I'm only allowed to read the text file once.
> Can anyone show me how to achieve this to give the same output that I have.
> 
> Any help would be appreciated Thanks  GREG   :-(

Okay, I'll try to help. I have cracked some new code for you, but I'll
put up my algorithm, if you still have problems you can email me
directly and get the code but I expect you will find you learn more
coding your own from the algorithm (besides not having to decipher my
code ;)

Please forgive any errors in the algorithm, I've only just started c/c++
this semester and I'm writing this at 3 am here in Australia.  I hope it
makes sense.  Also it's not optimised or anything for clarity :)

Philip Tillsley


Within main:

	// first 5 appropriate chars first
	while you haven't yet read five chars and this character read now is
not EOF {
		If it's a printable character {
			Make the appropriate CharArray this character
			Increment the appropriate NumArray also
			Increment your character counter (i)
		}
	}

	// then the rest of the file
	while this char read now is not EOF
		for i is 0 to 4 (ie. < 5) and it increments each time {
			if the char already read is the same as the ith element of CharArray
				increment your NumArray
			}
		}
	}

	// Now Print your graph, have your functions, etc...
}

-- 
 ___  _  ____  _  ____  ____  _  ____  _  ___ 
(___>(_)(____)(_)(____)(____)(_)(____)(_)<___)
 |_|                                      |_|
 (.)  Philip Tillsley    Robert Tillsley  (.)
 |_|                                      |_|
 (.)   Cabal:  Dark Fantasy Roleplaying   (.)
 |_|   _    _    _    __    _    _    _   |_|
 (.)--(_)--(_)--(_)--(__)--(_)--(_)--(_)--(.)
 |_|                                      |_|
 (.)     hovel@pasteur.dialix.com.au      (.)
 |_|   http://www.gameverse.com/newrpg    |_|
 |_|                                      |_|
(___),  ,   .   .,    ,, ,     .  .   ,  (___)
"~"~"~`"~""~`""~`""~""`~""~""``""~"`"~"`""~"~"
-- 
comp.lang.c.moderated - clcm@plethora.net
Technical Details
Message-ID: <clcm-19971115-0003@plethora.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <clcm-19971114-0010@plethora.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fab7a,75d4be5da465827f
X-Google-Attributes: gidfab7a,public
X-Google-Thread: 100850,75d4be5da465827f
X-Google-Attributes: gid100850,public
X-Google-Thread: 114592,75d4be5da465827f
X-Google-Attributes: gid114592,public
From: Philip Tillsley <hovel@pasteur.dialix.com.au>
Subject: Re: FILE READ PROBLEM
Date: 1997/11/15
Message-ID: <clcm-19971115-0003@plethora.net>
X-Deja-AN: 289750554
References: <clcm-19971114-0010@plethora.net>
Organization: DIALix Internet Services
NNTP-Posting-Date: 15 Nov 1997 11:39:32 CST
Newsgroups: alt.comp.lang.learn.c-c++,comp.lang.c.moderated,ctdl.lang.c
Originator: clcm@plethora.net (comp.lang.c.moderated)