#include<iostream>
using namespace std;

int main()
{
    char name;
    cout<<"Enter your name.\n";
    cin >> name;
    cin.get();
    cout<<"Hello, " << name;
    cin.get();
}

this is what I have..
Very simple program but I cannot get it to work, as soon as I enter two or more letters when debugging, the cmd crashes. I think it is because I am using char instead of another kind of variable, but i dont know what else to use! Please help. Thanks

A char is for a single character meaning if you type in "Hello" it will only save the 'H' to the char variable.

You can make a char array char myarray[size]; This will be able to hold as many characters in it as you have "size".

Or you can include the string header. #include <string> A string is similar to a character array but you do not have to specify the size of it upon declaration. string mystring; I would go check out this website for learning the basics of C++ it helped me out. here.

This simple change might help ye'

char name[80];

This array of chars (also known as a C-String) will provide you with 79 available char-containers in which ye' can populate with ascii characters. Remember, with c-strings to always make sure you have a '\0' NULL terminator somewhere in your array. Also, be sure to become familiar with the <cstring> library of functions that will make your life easier.

Thanks. I will be using that site. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.