-
Notifications
You must be signed in to change notification settings - Fork 0
/
join_group.c
47 lines (44 loc) · 1022 Bytes
/
join_group.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
43
44
45
46
47
#include <bits/stdc++.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <cstring>
#include <cstdlib>
#include <sys/wait.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <ctype.h>
#include <dirent.h>
using namespace std;
void join_group(char *uid,char *gid){
FILE *fp;
string path("/home/aklesh/public/group");
string grp(gid);
path+=grp+".txt";
if((fp=fopen(&(path[0]),"a+"))==NULL){
perror("Unable to open\n");
exit(EXIT_FAILURE);
}
fprintf(fp,"%s",uid);
fprintf(fp,"%s","\n");
fclose(fp);
}
/*int main(int argc,char **argv){
FILE *fp;
string path("/home/aklesh/public/group");
string grp(argv[2]);
path+=grp+".txt";
char *p=&(path[0]);
if((fp=fopen(p,"a+"))==NULL){
perror("Unable to open\n");
exit(EXIT_FAILURE);
}
fprintf(fp,"%s",argv[1]);
fprintf(fp,"%s","\n");
return 0;
}*/