All pastes #970309 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-03 23:25 UTC
rendered paste body
#include <iostream>
using namespace std;

int main() {
    int loopCount, counter;
    int myArray[6] = {97,98,99,100,101,102}; //declare an array?
    //it was erroring because we declared it as a char "a single character"
    //we were trying to put in words :)
    
    //let try to hcange it to an int datatype (integer)
    // lol see how strict it is?
    
    //cout << "enter a number (this will loop): ";
    //cin >> loopCount;
    
    //so, - set the counter to zero
    // - get the size of 'myArray'
    // - increment the counter.
    for(counter=0;counter<=sizeof(myArray)-1;counter++) {
            //ok, this is a for loop. we can use these
            //for alot of different things. lets go into
            //arrays, to help us with this....
            
            //so, lets lopp through the array
            //cout << myArray[counter] << endl;
            
            //now lets do something called "typecasting"
            //typecasting allows us to change the datatype for
            //a brief period of time.
            
            //remember, its  achar. so im typecasting it as an int when
            //it displays to the screen.
            
            //now typecasting to a char from an int
            cout << (char)myArray[counter] << endl;
            
            //those are the ascii values for those chars.
            //lets try it in reverse?
    }
    
    // forgot the pause :)
    //actually. we shoudl be running this from cmd line
    // windowskey+r
    system("pause");
    return 0;
}