Blog News


Because the real Opiate of the Asses goes by the name "Ego" now. Fuck you.

Sunday, March 11, 2012

The drawbacks of C++

The problem with programming in C++ is that there isn't really a reliable way to input strings. Strings are a type of variable, but instead of assigning that variable a number, you assign it a "string" of letters, otherwise known as a word. In even simpler terms, a string is a variable that stores a word.

In C++, there is no such thing as strings. All data put into a variable is converted to numbers. The only variable that stores letters is the "char" integer, but it stores letters in the form of their ASCII code. (every character on the keyboard has a number assigned to it, known as the ASCII number).

If you were to store the word "test" in a char variable, and then you told the program to print the word, instead of just printing "test", you would get something like
t
e
s
t

C++ is a very useful language, but it isn't that useful for making text-based games. I can either continue writing the program in C++ and just assign number values to each character (for example, to choose an attack type, you would type in '1' for melee, '2' for ranged and '3' for magic rather than typing the words themselves.), or I can find a different language that allows the use of strings, maybe Java.

1 comment:

  1. So maybe C++ will be helpful for our side project, as opposed to this. Although using numbers isn't always terrible... except that you may need to add extensive instructions for each user input.

    ReplyDelete