|
|
|
|
 |

April 5th, 2004, 12:56 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Dec 2000
Location: USA
Posts: 15,630
Thanks: 0
Thanked 31 Times in 19 Posts
|
|
Re: Coding Inquiry
If you want to write a program, write one that automatically breaks the files down into easy to follow and PRINTABLE tech trees for use with mods.
__________________
Creator of the Star Trek Mod - AST Mod - 78 Ship Sets - Conquest Mod - Atrocities Star Wars Mod - Galaxy Reborn Mod - and Subterfuge Mod.
|

April 5th, 2004, 08:26 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
|
|
Re: Coding Inquiry
Setting the characters to be newline characters is not used on any of the strings where this problem occurs. Earlier when reading in the components, I use the newline character because I want lines read in that are just newlines (blank lines) to be skipped. If getting a line results in the string being just a newline, it gets skipped. I don't think this has anything to do with having lots of stuff appended to the beginning of the char arrays in this section, as I do not reference this function, nor the buffer string.
I am well aware that strings are just arrays of characters, but the ofstream class is unfortunately not aware of this. :-\
|

April 5th, 2004, 08:26 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
|
|
Re: Coding Inquiry
Quote:
Originally posted by Atrocities:
If you want to write a program, write one that automatically breaks the files down into easy to follow and PRINTABLE tech trees for use with mods.
|
That would be rather hard to do... if each tech only had one level, it would be easy. But with lots of levels, it becomes messey... :-\
|

April 5th, 2004, 09:50 PM
|
 |
Second Lieutenant
|
|
Join Date: Nov 2003
Posts: 482
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Re: Coding Inquiry
I'm not sure if this will help or not, but I seem to remember needing to use the chop() function on strings.
(hmmm...can't seem to remember if this was a C++, or a Perl thing?)
[ April 05, 2004, 20:51: Message edited by: Cipher7071 ]
__________________
The great tragedy of science...the slaying of a beautiful hypothesis by an ugly fact. (T. H. Huxley)
|

April 5th, 2004, 09:51 PM
|
 |
General
|
|
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
|
|
Re: Coding Inquiry
You do know that all strings in C have to end with a null terminator, don't you?
Wouldn't it be better to use a string class that's available in many a C++ library? 
__________________
The Ed draws near! What dost thou deaux?
|

April 5th, 2004, 09:59 PM
|
 |
Shrapnel Fanatic
|
|
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
|
|
Re: Coding Inquiry
You miss the point... ofstream objects DO NOT ACCEPT strings. You have to use arrays of characters... this is where the problem lays, in trying to get an appropriate array of characters that are exactly the same as the string from which you are building it...
|

April 5th, 2004, 10:04 PM
|
 |
Lieutenant Colonel
|
|
Join Date: Mar 2001
Location: Emeryville, CA
Posts: 1,412
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: Coding Inquiry
Ummm... Fyron, I think you need to be introduced to the wonders of c_str().
code:
#include <string>
#include <fstream>
...
string aString;
...
ofstream outFile(aString.c_str()):
...
The c_str() method of string returns a pointer to a null-terminated array of char. Which is what the fstream classes take in their constructors.
__________________
GEEK CODE V.3.12: GCS/E d-- s: a-- C++ US+ P+ L++ E--- W+++ N+ !o? K- w-- !O M++ V? PS+ PE Y+ PGP t- 5++ X R !tv-- b+++ DI++ D+ G+ e+++ h !r*-- y?
SE4 CODE: A-- Se+++* GdY $?/++ Fr! C++* Css Sf Ai Au- M+ MpN S Ss- RV Pw- Fq-- Nd Rp+ G- Mm++ Bb@ Tcp- L+
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is On
|
|
|
|
|