Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "structs.h"
- void PrintRecord(struct user ben);
- int main()
- {
- struct user ben;
- struct user emily;
- printf("\nEnter customerID: ");
- scanf(" %d", &ben.customerID);
- printf("\nEnter time in 2016-12-11 12:34:56 format: ");
- scanf(" %s[^x]s", ben.timestamp); // '[^\n]' allows the user to type information including whitespaces.
- printf("\nEnter domain: ");
- scanf("%s", ben.domain);
- PrintRecord(ben);
- return 0;
- }
- void PrintRecord(struct user ben)
- {
- printf("\ncustomerID: %d\n", ben.customerID);
- printf("TimeStamp: %s\n", ben.timestamp);
- printf("Domain: %s\n", ben.domain);
- printf("%s: User %d visited %s\n", ben.timestamp, ben.customerID, ben.domain);
- }
- //Structs here are in a separate file called structs.h
- struct user {
- int customerID;
- char domain [255]; // 255 character limit
- char timestamp [21]; // 21 character limit
- };
Advertisement
Add Comment
Please, Sign In to add comment