Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -


variable type

  • Please log in to reply
2 replies to this topic

#1 Khaotic


    CC Resident

  • Just Joined
  • PipPipPipPip
  • 62 posts

Posted 24 May 2009 - 07:12 PM

Hey guys! I know it's been a while since my last tutorial. So, I thought I would make one on typecasting. This tutorial is gonna be ANSII chart basically.

Explaination of a typecast: It basically makes one variable type into another. So, basically I can take an integer variable and make it a character. The ANSII chart we are going to make is gonna be centered around the one on this site. If you are looking at this, I am assuming you know the basics of C++, so I wont explain the main function. For an explanation of a for loop, look at my tutorial. I am only going to explain the typecast.

The code:
#include <iostream>

using namespace std;

int main(void) {
for(int x=0;x <=127;x++){
cout << x << " = " << (char)x << endl;

cout << x << " = " << (char)x << endl;
Basically, I declared variable x as an integer. By placing (char) in front of it, I typecasted it into a character, meaning the value of x was changed into its ANSII value.

I know this wasn't that great, but it has been a while since I've written a tutorial, so meh... Any questions you may have, feel free to ask. I am always willing to help.
  • 1

#2 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 25 May 2009 - 04:57 AM

Just an observation: technically, that's a C-style cast, which is required for built-in types. Classes usually use dynamic_cast, static_cast, const_cast, and reinterpret_cast.

+rep :)
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

#3 Khaotic


    CC Resident

  • Just Joined
  • PipPipPipPip
  • 62 posts

Posted 25 May 2009 - 12:40 PM

heh...true...i havent coded in a while either. Last week was my last week of school.
  • 0
Check out my site: www.khaoticirc.net

Also tagged with one or more of these keywords: variable type

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download