Hello, I just started programming a few days ago, and I am desperately looking for an answer to my prayers! :P
How do I use words in variables?
I can only do int blabla = random number.. But I don't want that, I want my program to be able to use letters in input, for example:
int main()
{
variable word; // whatever the command is named
you were missing substantial code in your function, take a look at the revised code with comments included, good luck!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>// the header iostream, which supports the C++ I/O system
#include <cstdlib> //c++ standard library header
usingnamespace std; //this tells the compiler which namespace to use
int main()//calls the function 'main()', execution begins here
{ // formally starts execution
char word[80];//this statement identifies 'word' as a character string
cout << "Type in a word\n";// '\n' console output/creates a new line
cin >> word;//console input /input character string
cout << "you typed this word:\n" << word; // output character string entered
return 0; // This line terminates main( ) and causes it to return the value 0 to the calling process
}// formal end of function
Type in a word
Serendipity
you typed this word:
Serendipity
well from some of the input ive been getting back Bazzy, the herbert shildt guide for beginners isnt the best one to sink your teeth into if your a beginner, however, I am on chapter 7 of 12, so i will finish it then get a different one learn from, so in essence i will be taking two beginner courses due to perceived neccesity on my part, i actually found a mistake when transcribing notes yesterday in chapter 2 where he went into great detail stating that integers were by default signed integers and thats why they could hold a negative value,, well, i wasted 20 minutes scratching my head and rereading until i changed my notes on my own to unsigned, then moved on to the next page where he was correct in further references to signed. that WAS confusing
Herbert Schildt's C++ Beginner's Guide is the one I am using, i mentioned it in the forum and got some feedback that it isnt all that encompassing, he was on the ansi/iso committee that standardized c++, I think it is a good beginners guide, but the syntax is much different than what I regularly see here, so I will need to compliment it with another beginners book, any suggestions?
You hijacked the thread with your comment. Take a look at C++ How to Program (6th Edition) also 7th edition was just released. It is alll encompassing including Boost, Ogre3d, UML, etc...