101
{ USER }
posts: 55
last: 09-Apr-2008
TITLE: Accepting Characters with CIN
DESCRIPTION: Read a character using cin
Submitted: 09-Apr-2008 08:31:48 ( 38w 5d 22h ago ) Language: C++ (*.cpp *.h)
Views: 68 Lines of Code: 25 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Beginner
Bookmark
/* Author: 101
   Date: 09-04-2008
   Filename: 
   Description: Read a character using cin
   History: 
*/


#include <iostream.h>
#include <stdlib.h>

int main()
{
    char mychar[100];
    int i = 0;
    //while the character is not a new line
    while((mychar[i] = cin.get()) != '\n')
    i++;

    mychar[i] = NULL;
    //display characters
    cout<<mychar<<endl;

    return 0;
}