Perdes

Code

Nov 28th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "structs.h"
  4.  
  5. void PrintRecord(struct user ben);
  6. int main()
  7. {
  8. struct user ben;
  9. struct user emily;
  10.  
  11. printf("\nEnter customerID: ");
  12. scanf(" %d", &ben.customerID);
  13.  
  14. printf("\nEnter time in 2016-12-11 12:34:56 format: ");
  15. scanf(" %s[^x]s", ben.timestamp); // '[^\n]' allows the user to type information including whitespaces.
  16.  
  17. printf("\nEnter domain: ");
  18. scanf("%s", ben.domain);
  19.  
  20. PrintRecord(ben);
  21.  
  22. return 0;
  23. }
  24.  
  25. void PrintRecord(struct user ben)
  26. {
  27. printf("\ncustomerID: %d\n", ben.customerID);
  28. printf("TimeStamp: %s\n", ben.timestamp);
  29. printf("Domain: %s\n", ben.domain);
  30. printf("%s: User %d visited %s\n", ben.timestamp, ben.customerID, ben.domain);
  31. }
  32.  
  33.  
  34. //Structs here are in a separate file called structs.h
  35.  
  36. struct user {
  37. int customerID;
  38. char domain [255]; // 255 character limit
  39. char timestamp [21]; // 21 character limit
  40. };
Advertisement
Add Comment
Please, Sign In to add comment