Go to Post Bottom line is I love FIRST and what it stand for. Hold nationals in a corn field on old crates and I'll support it! If the FIRST staff is reading, Thank you for all the hard work you do! - Gene F [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 24-06-2002, 02:03
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,604
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
try a union

here is another solution using an union. This is better in that more people are probably able to figure out what it does, as opposed to the <?. However, it uses 4 bytes for each char, rather then just 1.

Code:
#include <iostream>

typedef union
{
	unsigned char byte;
	unsigned int print;
} chars;

void main(void)
{
	chars test1;
	test1.print = 0;	// must initialize all 4 bytes to 0

	test1.byte = 255;

	cout << test1.print << " " << test1.byte << endl;
}
Matt, I think when Mike said that a char was 4 bytes, he meant that when he cast the char to unsigned int, it printed out a number that could only be represented in 4 bytes, which would make sense becasue of the casting. To consider UTF-8, etc is just too much thinking ;-)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dashboard Decoder Release Version 1.0 Now Available! archiver 2000 1 23-06-2002 22:50


All times are GMT -5. The time now is 07:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi