101
{ USER }
posts: 55
last: 09-Apr-2008
TITLE: Cout and cin examples
DESCRIPTION: Cout and cin examples
Submitted: 09-Apr-2008 07:52:42 ( 38w 5d 23h ago ) Language: C++ (*.cpp *.h)
Views: 125 Lines of Code: 41 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 101
   Date: 09-04-2008
   Filename: 
   Description: Cout and cin examples
   History: 
*/


//read a character using cin 
#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;
}

//write a character using cout

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

int main()
{
char *url = "WWW";
while(*url)
cout.put (*url++);

cout<<endl;
return 0;
}