-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc.cpp
More file actions
80 lines (62 loc) · 1.55 KB
/
abc.cpp
File metadata and controls
80 lines (62 loc) · 1.55 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <string.h>
#include <emscripten.h>
#include <emscripten/bind.h>
using namespace emscripten;
char* EMSCRIPTEN_KEEPALIVE viewc(char* email);
char* EMSCRIPTEN_KEEPALIVE entryc(char* name, int sid, char* email, int mark1, int mark2, int mark3 );
//emcc -s NO_EXIT_RUNTIME=1 -s EXPORTED_FUNCTIONS="['_world','_viewc','_entryc']" abc.c -o abc.js
struct student
{
int studentid;
char name[14];
char email[14];
int m1,m2,m3;
float avg;
} s[10];
int pos = 0;
int count = 0;
//char a[14];
// char* world(char* uname, char* pwd) {
// char user[10][2];
// strcpy(user[0][0],uname);
// strcpy(user[0][1],pwd);
// int i,j;
// for(i=0;i<10;i++)
// {
// for(j=0;j<2;j++)
// {
// if(user[i][j] == user[0][0])
// {
// if(user[i][j] == user[0][1])
// //return user[i][0];
// printf("login works");
// }
// }
// } return user[i][0];
// }
char* EMSCRIPTEN_KEEPALIVE viewc(char* email) {
char temp[] = "Invalid";
for(count=0;count<50;count++)
{
if(strcmp(s[count].email,email)==0)
return (s[count].name);
else
return "temp";
}
return "err";
}
char* EMSCRIPTEN_KEEPALIVE entryc(char* name, int sid, char* email, int mark1, int mark2, int mark3 ) {
strcpy(s[pos].name,name);
s[pos].studentid = sid;
strcpy(s[pos].email,email);
s[pos].m1 = mark1;
s[pos].m2 = mark2;
s[pos].m3 = mark3;
s[pos].avg = (mark3+mark2+mark1)/3;
pos++;
return (s[pos-1].email);
}
int main() {
//emscripten_exit_with_live_runtime();
return 0;
}