.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old April 5th, 2004, 10:39 AM
Jack Simth's Avatar

Jack Simth Jack Simth is offline
Major General
 
Join Date: Oct 2002
Posts: 2,174
Thanks: 0
Thanked 0 Times in 0 Posts
Jack Simth is on a distinguished road
Default Re: Coding Inquiry

Just at a glance, I suspect your problem is the various incarnations of
code:
for(int i = 0; i < BUFFER_SIZE; i++)
{
buffer[i] ='\n';
]

for clearing out your strings; if this is it, then the problem would be that "standard" strings are terminated with a 0 in c, not with the newline character (this may vary by OS, if the one you are used to working in uses a 0 for the newline character). Your internal representation of strings appears to use the newline character for terminating, but then you turn around and use standard routines for output - the standard routines output the newline, don't see a 0, and so keep going through memory, spouting whatever happens to be there, until they do hit a 0. The suggested fix, bearing in mind that the possibility exists that this isn't actually the problem; I don't have great experiece with c, would be to change the various incarnations of the above to
code:
for(int i = 0; i < BUFFER_SIZE; i++)
{
buffer[i] = 0; /* yes, c does allow you to give a character a numeric value */
]

and then have the newline character tacked on in your output routines.

Edit:
Also, c strings *are* character arrays already; further, you may want to go through and set it up to destroy some of those dynamic variables you keep allocationg

[ April 05, 2004, 09:41: Message edited by: Jack Simth ]
__________________
Of course, by the time I finish this post, it will already be obsolete. C'est la vie.
Reply With Quote
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:24 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.