-
Notifications
You must be signed in to change notification settings - Fork 1
/
struct_user.c
42 lines (29 loc) · 917 Bytes
/
struct_user.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
#include<stdlib.h>
//Stucture User
struct user{
char name[20],password[30],security_question[200];
int no_of_valid_attempts;
float fine;
};
//Main Class
int main(){
//Pointer
struct user *user;
//Memory Allocation using Type Casting
user=(struct user * )malloc(sizeof(struct user));
//Accept Values
printf("Enter Username : ");
scanf("%s",user->name);
printf("Enter Password : ");
scanf("%s",user->password);
printf("Security Question ? ");
scanf(" %[^\n]s ",user->security_question);
printf("No. of Attempts : ");
scanf("%d",&user->no_of_valid_attempts);
printf(" Fine Charged : ");
scanf("%f",&user->fine);
//Output
printf("Enterd Values : \n Username : %s \n Password : %s \n Security Question : %s \n No. of Attempts : %d \n Fine : Rs. %f\n",user->name,user->password,user->security_question,user->no_of_valid_attempts,user->fine);
return 0;
}