Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "make_msg.c"
- char* concat(const char *s1, const char *s2)
- {
- char *result = malloc(strlen(s1) + strlen(s2) + 1);
- strcpy(result, s1);
- strcat(result, s2);
- return result;
- }
- void create_msg_file(char *fname, int n, int taille_info)
- {
- int size_msg = 0;
- char *msg_res = malloc(n * (taille_info + 10));
- FILE *file = NULL;
- fname = concat(fname, ".msg");
- file = fopen(fname, "wb");
- int i;
- for(i = 0; i < n; i++)
- {
- char *msg = make_msg(i, taille_info, &size_msg);
- printf("buff:%s", msg);
- if(i > 0)
- msg_res = concat(msg_res, msg);
- else
- msg_res = msg;
- }
- fwrite(msg_res, 1, strlen(msg_res), file);
- fclose(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement