I was looking over a program this morning, and I noticed a tab '\t' was assigned to a char variable and it got me thinking. How can a tab be a character when it consistis of many 'spaces' which are characters?
I was looking over a program this morning, and I noticed a tab '\t' was assigned to a char variable and it got me thinking. How can a tab be a character when it consistis of many 'spaces' which are characters?
Clear the mines from our Shazbot!
Get the enemy Shazbot!
Tab is not really a "character" as much as it is a command for formatting. You'll notice that tabs are set to all different sizes depending on what program is processing the text file. The "tab" is represented as a character, because this and many other formatting commands are represented in text files as ASCII numbers. A "char" in C++ is a variable that can hold any of these numbers and thus their corresponding symbol. IT can hold the alphabet, upper or lower case, the numbers, common symbols, and of course, formatting commands. I can't think of a better way to send the format commands.
a tab isn't really many spaces... a tab is a tab... many spaces can sometimes be considered equivalent, but in reality it's not. a tab is a blank amount of space used for formatting. unless your text editor converts tabs to spaces, when you send a \b (backspace), it should delete the tab, not 1/5 (or however many spaces) of it. also, it reacts differently. tabs are usually set (sometimes at every half-inch), and sometimes padded on the left so that your output would look like this:
whereas spaces would look like this:Code:hello 123456 hi 123456
here is a useful list of escape sequences, most of which you'll likely use at one time or another.Code:hello 123456 hi 123456
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
Oooook.
Alright major_small, i got it now, it all makes sense. Very good job at explaning it too. Cheers
Clear the mines from our Shazbot!
Get the enemy Shazbot!
really? I looked back at that and realized how bad it really came out...Originally Posted by jrahhali
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT