forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

file io strange extra text or data?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Mon May 15, 2006 10:53 pm    Post subject: file io strange extra text or data? Reply with quote

Hi folks,

i try to write 4 sentences to a textfile is use:

Code:
   int Output(const char *sMsg){

      int fdout;
      
      char writepath[200];

      sprintf(writepath, "%s\n", sMsg);

      fdout = sceIoOpen("output.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND | PSP_O_TRUNC, 0777);
      if(fdout < 0)
      {

      }

      sceIoWrite(fdout, writepath, 200);

      if(fdout >= 0)
      {
         sceIoClose(fdout);
      }
      return 0;
   }


however for some strange reason (well strange for me) it also write some strange data. i open it through wordpad or notepad in both the data is visible. is there a way of removing this or am i doing something wrong?


greets
[/code]
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Arwin



Joined: 12 Jul 2005
Posts: 426

PostPosted: Mon May 15, 2006 11:05 pm    Post subject: Reply with quote

Do I see correctly that you are forcing it to write out 200 bytes, even though your string is probably less? I think you need to use a WriteLn function. Otherwise you'll have to specify the actual length of the string up until the newline.
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Mon May 15, 2006 11:13 pm    Post subject: Reply with quote

What arwin said is the case...

..except isn't writeln a pascal function? ;)

I'd recommend looking at fprintf.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Mon May 15, 2006 11:26 pm    Post subject: Reply with quote

yess thanks, i tried sizeof first but i had to use strlen :) now it works fine thank you
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group