| View previous topic :: View next topic |
| Author |
Message |
Ghoti
Joined: 31 Dec 2005 Posts: 288
|
Posted: Mon May 15, 2006 10:53 pm Post subject: file io strange extra text or data? |
|
|
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 |
|
 |
Arwin
Joined: 12 Jul 2005 Posts: 426
|
Posted: Mon May 15, 2006 11:05 pm Post subject: |
|
|
| 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 |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Mon May 15, 2006 11:13 pm Post subject: |
|
|
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 |
|
 |
Ghoti
Joined: 31 Dec 2005 Posts: 288
|
|
| Back to top |
|
 |
|