Advertisement
Guest User

Untitled

a guest
May 30th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. Cout and cin examples
  2.  
  3. //read a character using cin
  4. #include <iostream.h>
  5. #include <stdlib.h>
  6.  
  7. int main()
  8. {
  9. char mychar[100];
  10. int i = 0;
  11. //while the character is not a new line
  12. while((mychar[i] = cin.get()) != '\n')
  13. i++;
  14.  
  15. mychar[i] = NULL;
  16. //display characters
  17. cout<<mychar<<endl;
  18.  
  19. return 0;
  20. }
  21.  
  22. //write a character using cout
  23.  
  24. #include <iostream.h>
  25. #include <stdlib.h>
  26.  
  27. int main()
  28. {
  29. char *url = "WWW";
  30. while(*url)
  31. cout.put (*url++);
  32.  
  33. cout<<endl;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement