char str[80]; // create buffer (1 extra for null char)
cin.get(str, 79); // read up to 79 chars and place in str
You could also dynamically allocate the array to minimise memory usage. I don't know how efficient or inefficient or useful this is, maybe someone else could comment?
You just have to add something to make the program stop and not exit out after it shows the input. I use cin.get(); which waits for the user to press enter.
If I change line 12 to delete [] &buf which is what I meant to put is there still a problem with it?
Yes!
1: buf is not dynamically allocated, it's allocated on the stack =>> you don't have to manually delete[] it.
2: altough str IS dynamically allocated which you don't delete[] anywhere =>> memory leak.
3. Even if bufwas dynamically allocated like char *buf = newchar[80];, then you wanna release the memory like this : delete [] buf;, without the & operator