Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2. char name[64];
  3.  
  4. int main(int argc, char*argv[]) {
  5. char message[64];
  6. FILE *fp;
  7.  
  8. setvbuf(stdout, NULL, _IONBF, 0);
  9.  
  10. printf("Enter your name: ");
  11. fgets(name, 63, stdin);
  12.  
  13. printf("Enter your message: ");
  14. gets(message);
  15.  
  16. fp = fopen("messages.txt", "a");
  17. if(fp == NULL) {
  18. printf("Whoops, message not delivered ;(\n");
  19. return 1;
  20. }
  21. fprintf(fp, "Message from %s: %s\n", name, message);
  22. fclose(fp);
  23.  
  24. printf("Your message has been sent to admin, bye!\n");
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement