-
September 12th, 2004, 04:12 PM
#11
But, lepricaun, nicer code is a bigger part of coding, why use code that isn't optimized. I recommend you get one of the begining programming books, that don't teach code, but teach theory. They will be very good for you. They will teach you to, optimize your code.
That is one of the problems i have with my Algo's.
Your code isn't bad, it's just the best it could be.
yeah i know, i just started reading some tut's about optimizing code
-
September 12th, 2004, 05:30 PM
#12
Gotta say though, I dunno whether it was the same with you lot but when i did a C programming course at uni the bloke was obsessed with using fclose and put it everywhere as he said it was to prevent the file becoming corrupt in a crash,
He even marked people down for not using it enough, so i dunno whether this is why you put it in loads, but i think its quite an old fashion thing to do really.
i2c
-
September 12th, 2004, 08:08 PM
#13
Gotta say though, I dunno whether it was the same with you lot but when i did a C programming course at uni the bloke was obsessed with using fclose and put it everywhere as he said it was to prevent the file becoming corrupt in a crash,
He even marked people down for not using it enough, so i dunno whether this is why you put it in loads, but i think its quite an old fashion thing to do really.
that might be why i done this too, like i said, i can't really remember, but i did it for a reason, thats for sure
-
September 12th, 2004, 10:08 PM
#14
i2c: I'm not advocating LEAVING THE FILE OPEN, I'm just advocating consolidating a large number of fclose() calls to one.
Surely your tutor can't mind me using as few calls as possible, if it gets the job done?
Other people have talked about optimisation. I'm not remotely concerned with this, I'm more concerned with tidyness and conciseness.
If you need fclose() in 101 places in your program (and only one fopen()), it's a general indication that there's something wrong with its structure.
Slarty
-
September 13th, 2004, 08:49 AM
#15
yea slarty I fully agree that the file shouldnt be left open, I was just woundering whether this might be way lepricaun was doing it,
I do agree with you that the source should be kept concise, and agree with the argument to remove many of the fclose() statements.
i2c
-
September 14th, 2004, 08:47 AM
#16
Like i said before, i did it on purpose, but what exactly my reason was i can't really remember, the only thing i can think of is indeed making sure the output file is save and can be altered / removed / opened /copied whenever you want it, without having to shutdown the program
-
September 14th, 2004, 12:09 PM
#17
Junior Member
When you have a several handles allocated for a single file, it's possible (very likely) things will get corrupted. However, it's a good programming practise to exercise caution with an open file handler (and all other things). So no need to close the file every other line. After all, isn't being cautious all what programming is about ).
There are 10 kinds of people, those who can read binary, and those who can\'t.
-
September 14th, 2004, 02:44 PM
#18
Senior Member
I tried to compile this with Dev C++. It would not complie, do I need to manually create the scvhost.log file first?
There are many rewarding oppurtunities awaiting composure from like minds and great ideas. It in my objective to interconnect great things.
-
September 14th, 2004, 06:58 PM
#19
Junior Member
Fraggin: I believe so. Don't hold me to it though. When compiling SWR 1.0 code (I am a mudder, the SWR 1.0 is a Star Wars based code base), you have to create a log file before you compile the code. In this case, create a file called "svchost.log".
Not sure if that will work or not, havn't tried compiling this code yet (and probably won't), but Kudos to you Lepricaun, this coming from an amateur C programmer such as myself.
Don\'t mistake lack of talent for genius.
-
September 14th, 2004, 07:44 PM
#20
i ran it on my computer ...it creates the log file itself. but the existance of the log file does not effect the compileing. it creates the log file at run timewhat error messages are you getting?
Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|