char array not terminating
Subject : char array not terminating
From: Michael Hanna <email@hidden >
Date: Mon, 2 Jan 2006 21:47:12 -0800
Delivered-to: email@hidden
Delivered-to: email@hidden
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:content-transfer-encoding:message-id:content-type:to:from:subject:date:x-mailer; b=dw+pQPdDxH3CjKKfm5q7qOJqZPH8ejTIUBETsi6T+iaUmV0huBnEmlbvUKijZH0ZhzUMKPPqodoTBxq39BlNoGEZmxVeDdkTzisoiQyn/Uvf5sf0mOMEnlQO1vwFut0h93beU+25Sac+wK6q9dFV9H8OHsRDhlex8pOGlcjzrag=
I want to be able to XOR a char array, but it doesn't seem to be
terminating properly any ideas how to do this?
Michael
char * foo;
foo = malloc(4);
char tempFoo[] =
{ 'f'^0xc2,
'o'^0xc2,
'o'^0xc2,
0x0
};
memcpy(foo, tempFoo, 4);
for(i = 0 ; i < 4 ; i ++)
{
tempFoo[i] = tempFoo[i]^0xc2;
}
printf("foo %s\n", foo);
printf("tempFoo %s\n", tempFoo);
NSLog(@"tempFoo, %@", [NSString stringWithUTF8String:tempFoo]);
foo \244\255\255
tempFoo foo\302
2006-01-02 19:07:19.958 GuitarPrompter[2710] tempFoo, (null)
_______________________________________________
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
This email sent to email@hidden
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.