| View previous topic :: View next topic |
| Author |
Message |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 1:32 am Post subject: How to write a Hex value in a file... |
|
|
Sorry for my bad english, I'm italian ^^'
I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
| Code: | int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
sceIoWrite(fd, i1, sizeof(i1)); |
But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.
Please, could anyone help me? :(
EDIT: the Hex value that i would to write in the offset is "08". |
|
| Back to top |
|
 |
Alberto
Joined: 12 Feb 2007 Posts: 57 Location: Sofia
|
Posted: Thu Jan 17, 2008 2:25 am Post subject: Re: How to write a Hex value in a file... |
|
|
| Red_Squirrel wrote: |
I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
| Code: | int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
sceIoWrite(fd, i1, sizeof(i1)); |
But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.
Please, could anyone help me? :(
EDIT: the Hex value that i would to write in the offset is "08". |
and what does i1 contain, as a char??? you should do i1 = 0x08 before writing it to the file, I assume... |
|
| Back to top |
|
 |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 3:11 am Post subject: |
|
|
| Usually i1 contains letters, like "A", "B", "C" or other char as "?", "!", "("... |
|
| Back to top |
|
 |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 3:37 am Post subject: Re: How to write a Hex value in a file... |
|
|
| Alberto wrote: | | Red_Squirrel wrote: |
I want to write a Hex value in a file.
I already made a function to hex modify a file, and I use this code to write in a precious offset:
| Code: | int pos = sceIoLseek(fd, 0x46A8, SEEK_SET);
sceIoWrite(fd, i1, sizeof(i1)); |
But it writes an ASCII value (i1 is a char value) in the offset position...
I need to modfy the hex value of the offset and not the ASCII one.
Please, could anyone help me? :(
EDIT: the Hex value that i would to write in the offset is "08". |
and what does i1 contain, as a char??? you should do i1 = 0x08 before writing it to the file, I assume... |
No, it does not work :( |
|
| Back to top |
|
 |
Mihawk
Joined: 03 Apr 2007 Posts: 29
|
Posted: Thu Jan 17, 2008 4:31 am Post subject: |
|
|
hint:
| Code: | | int sceIoWrite(SceUID fd, const void *data, SceSize size); |
P.S.:
How do you know that it writes an ASCII value and not a HEX one?
And why don't you like ASCII values? Is it just because HEX sounds cooler? Ok, you say your english is not so good, but do you know what discrimination is? _________________ Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. |
|
| Back to top |
|
 |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 4:43 am Post subject: |
|
|
| Mihawk wrote: | hint:
| Code: | | int sceIoWrite(SceUID fd, const void *data, SceSize size); |
P.S.:
How do you know that it writes an ASCII value and not a HEX one?
And why don't you like ASCII values? Is it just because HEX sounds cooler? Ok, you say your english is not so good, but do you know what discrimination is? |
I need to insert the "08" hex value in the file... in ASCII it has not a value :|
With a hex editor I saw that "08" value is egual to a "." value, but if I insert with the keyboard the "." value in the ASCII column, in the hex one appear the code "2E"... but I need 08...
Could anyone help me?
Please... |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jan 17, 2008 5:29 am Post subject: |
|
|
| Writing data to a file is beginner programming. Go look at a general C tutorial or programming book. We aren't going to help with beginner stuff here. |
|
| Back to top |
|
 |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 5:34 am Post subject: |
|
|
| J.F. wrote: | | Writing data to a file is beginner programming. Go look at a general C tutorial or programming book. We aren't going to help with beginner stuff here. |
So you don't know how to do it... |
|
| Back to top |
|
 |
Red_Squirrel
Joined: 03 Oct 2007 Posts: 11
|
Posted: Thu Jan 17, 2008 5:59 am Post subject: |
|
|
Ok guys, no problem :)
Thanks to all for the help and see you later ;) |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Thu Jan 17, 2008 6:36 am Post subject: |
|
|
It's the difference between
unsigned char i1 = 8;
and
unsigned char i1 = '8';
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Jan 17, 2008 6:38 am Post subject: |
|
|
| sceIoWrite takes a pointer as the second argument, not a value. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jan 17, 2008 7:58 am Post subject: |
|
|
| Again, that's all beginner programming. If the person can't tell the difference between using a pointer and using a value, or between 8 and '8', they aren't ready to program the PSP. They need more lessons in C. |
|
| Back to top |
|
 |
|