Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. struct messaggio { char msg[100]; };
  7.  
  8. messaggio a;
  9.  
  10. void scrivi()
  11. {
  12. ofstream fout("chat.txt");
  13. cout <<">> "; cin>>a.msg;
  14. fout.write((char *) &a, sizeof a);
  15. fout.close();
  16. }
  17.  
  18. void leggi(){
  19. ifstream fin("chat.txt");
  20. cout <<"Out >>: "<<a.msg<<endl;
  21. fin.close();
  22. }
  23.  
  24. int main() {
  25. while(true) {
  26. leggi();
  27. scrivi();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement