Thanks @DZee but I'm a C++ newbie (this is "for begginer") and I was wondering if you or anyone else could help me understand your suggestion I mean wth is code tags and some of the functions you put in your code well .. I don't know them :| pls help
Code tags are not part of programming, but part of this forum's (and many other forums') features.
They look like this:[ code ]
MY CODE GOES HERE [ /code ]
...but without spaces between the brackets.
When your post is posted, it turns into this:
MY CODE GOES HERE
...which is important when posting an entire file of code, since it puts it in a scroll-box instead of making the web page super long.
To re-iterate what JWalsh and the others are saying, an 'int
' is a number (standing for integer
, a math term). You are assigning a letter (the letter 'k
') to a number, and are understandably getting weird results. It'd be better to assign to a std::string
std::string (or just 'string
' if you use 'using namespace std
') is a group of characters (letters, symbols, or numbers). If you want to use std::string, you need to #include the <string> header.
Your code would then look like this:
#include <string> //Don't forget the <string> header!
using namespace std;
cout << "Please type some letters, symbols, or numbers which will then be printed out: ";
cin >> text;
cout << text;
Edited by Servant of the Lord, 25 July 2012 - 10:56 PM.