| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On 29 Apr 2006, at 16:49, Patrick Seemann wrote:
Am 29.04.2006 um 16:09 schrieb Phil Faber:
The following code successfully copies a file, byte-by-byte. It uses fread(&oneByte,1,1,fp1) to read in a byte and fwrite(&oneByte, 1,1,fp2) to write that byte back to disc.
I want to be able to analyse the byte before it writes back to disc but can't see how to see its value. oneByte is a pointer to the value - not the value itself. I need to do something like:
oneByteASCII=(value of byte at pointer 'oneByte')
You already got the value of the byte in 'oneByte' (which is not a pointer but an integer variable) so you may just do with it whatever you want.
You may also consider
- declaring oneByteASCII as 'char' and assigning it with 'oneByteASCII = (char) oneByte;'
// Used to store currently read byte int oneByte, oneByteASCII;
// Provide dialogue box to select file
NSOpenPanel *panel = [NSOpenPanel openPanel];
int result = [panel runModalForDirectory:nil file:nil types:nil];
// Put file name into inputFile NSString *inputFile = [panel filename]; NSMutableString *outputFile;
outputFile = [NSMutableString stringWithFormat: @"%@-A", inputFile];
// Prepare file pointer to open selected file FILE *fp1;
// Prepare file pointer to write to output file FILE *fp2;
// Set file pointer to selected file fp1 = fopen([inputFile UTF8String],"rb"); fp2 = fopen([outputFile UTF8String],"wb");
// Read a byte fread(&oneByte,1,1,fp1);
while(feof(fp1)==0)
{
// ** This is not legal code but shows what I'm trying to achieve here! **
oneByteASCII=(value of byte at pointer 'oneByte');
// Write the byte fwrite(&oneByte,1,1,fp2);
// Read next byte fread(&oneByte,1,1,fp1); }
// Close files fclose(fp1); fclose(fp2);
_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
| References: | |
| >-[NSAttributedString initWithData:...] compresses spaces? (From: Glen Simmons <email@hidden>) | |
| >How to access the value that a pointer is pointing to (From: Phil Faber <email@hidden>) | |
| >Re: How to access the value that a pointer is pointing to (From: Patrick Seemann <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.