Tuesday, May 1, 2012

Conversion table of numbers from char to int, for problem 7 of chapter 7.

This is just a handy list I will be leaving here. Who knows, I might even have a use for it later.

  • 0 in char is 48 in int
  • 1 in char is 49 in int
  • 2 in char is 50 in int
  • 3 in char is 51 in int
  • 4 in char is 52 in int
  • 5 in char is 53 in int
  • 6 in char is 54 in int
  • 7 in char is 55 in int
  • 8 in char is 56 in int
  • 9 in char is 57 in int

And this is the code I used to get the values:

File contents of SourceCode.cpp
 #include <iostream>  
 using namespace std;  
   
 int main(){  
 char charone = '0';  
 int intone = charone, counter = 1;  
   
 while(counter <= 10){  
 cout << endl;  
 cout << charone << " in char is " << intone << " in int";  
 cout << endl;  
 intone++;  
 charone = intone;  
 counter++;  
 }  
   
 return 0;  
 }  

Hating emacs and debugging...

My hate for emacs got me to find a really nice linux IDE called Eclipse CDT. It was quite heavy to download, but worth it. It's almost like Microsoft Visual Studio Express 2010. So far, debugging in Eclipse has been a breeze. Still better in my humble opinion than emacs.


PS: Thank you hate. You really are useful sometimes.

Wednesday, April 25, 2012

Final script updates for ultimate laziness...

So, here is now my new, and most recent, "cal" batch script and the new "execute program" batch script:

File contents of "cal.bat":
 @echo off   
 echo Compiling and linking the C++ source code,  
 echo and preparing the executable for debugging...  
 g++.exe -Wall -g -o executable SourceCode.cpp  
 pause  

File contents of "execute program.bat":
 @echo off  
 executable.exe  
 pause  


PS: The little "pause" command at the end of each file freezes the Command Prompt window until I press any key, which makes me able to see the contents of the window without it automatically closing right after the compilation or the execution of the program was complete...


Let the double-click heaven begin!!

ideone.com - Best. Site. Ever.

First I got rid of linux by installing MinGW and MS Visual Studio Express, and now I'm basically getting rid of my whole computer as long as I have a device I can type stuff into a website. I don't need a computer at all to test my programs! ideone.com rocks.

PS: For some reason I feel like making and advertising right now...

Sunday, April 22, 2012

Back in buisness...

I know, I know, I've been awfully lazy lately. I just wish I had a huge break by now. I still don't want to do anything at all, but I don't want a bad grade either. Well, here's some stuff I've written down a bit in my notebook. Here is a list of what has been defined in class so far and in which directive they reside so that every time I start programming, if I need to look down something to see where it was defined, I can just take a look at this list and include the directive I need in my source code. I still need to update some of it though.

I. List of primitive types:
    This list should be enough.


II. List objects, operators and member functions from <iostream>:


Objects:

  1. cout
  2. cin
Operators:
  1. >> - extraction operator
  2. <<  - insertion operator
Member funcions:
  1. setf(... :: ...)
  2. precision(n)


III. List of classes, operators and member functions from <fstream>:


Classes:

  1. ifstream
  2. ofstream
Operators:
  1. >> - extraction operator
  2. <<  - insertion operator
Member funcions:
  1. setf(... :: ...)
  2. precision(n)


IV. List of manipulators from <iomanip>
  1. setw(n)
  2. setprecision(n)
V. List of functions from <cctype>
  1. toupper(char_variable) - Returns an int value
  2. tolower(char_variable) - Returns an int value
  3. isupper(char_variable) - Returns a boolean vaue
  4. islower(char_variable) - Returns a boolean value
  5. isalpha(char_variable) - Returns a boolean value
  6. isdigit(char_variable) - Returns a boolean value
  7. isspace(char_variable) - Returns a boolean value
------------End of List-------------

Those are basically the lists. I'll probably be updating those so that I just have to search within this text in order to find what I need to include in my source code. Oh, and before I forget, I need to write these couple of important sentences down:

  1. Every Variable is an Object, but not every Object is a Variable (i.e. the objects are a proper subset of the variables).
  2. Every Type is a Class, but not every Class is a Type. (i.e. the classes are a proper subset of the types.)
  3. An object is an element of a Class.
  4. A variable is an element of a Type that is not a Class.
I think that will be it for this post...


Edit (April 25): I think I'm missing a list...

Friday, March 23, 2012

Integer division for the win!

Integer division is SO useful. I can't believe I made the Arabic to Roman numerals converter using that. The program is even able to write numbers from 0 to 3000 (instead of 1000 to 3000) which is amazing! I can't believe I'm so excited for something that silly, haha!

By the way, just a reminder to myself: Integer division and modular arithmetic are NOT the same.


I need to get that into my head...

Thursday, March 22, 2012

Ugh... stupid "break;" >.>

Programming is frustrating... a little bit. I spent like 10 minutes looking for a really small error I couldn't get to find by myself, until I used a debugger to get to it. I just missed a "break;" inside my switch statement and my string variables went crazy changing.

Note to self:
      Write more carefully. It's better to take my time writing the program, than to write it as fast as I can and, later, lose a bunch of time looking for mistakes.


Update:
     UGH! Found another one. I can't believe this. Next time I'm seriously going to take my time and my patience to write one.