int main(void) { char *a = "Hello, "; char *b = "World"; printf("Concatenated string is %s\n", concatenate_strings(a, b)); return 0; }
void create_and_open_files(FILE * output, FILE * output_MCS, FILE * output_m, char * latticesize, char * p, char * NOR) { char * three_strings = malloc(strlen("SM1_Data/N=") + 2*strlen(latticesize) + strlen("_Runs/") + strlen(p) + strlen(NOR) + 3 + strlen("_MCS_930.dat")); char * three_strings2 = malloc(strlen("SM1_Data/N=") + 2*strlen(latticesize) + strlen("_Runs/") + strlen(p) + strlen(NOR) + 3 + strlen("_NC_930.dat")); char * three_strings3 = malloc(strlen("SM1_Data/N=") + 2*strlen(latticesize) + strlen("_Runs/") + strlen(p) + strlen(NOR) + 3 + strlen("_m(t)_930.dat")); concatenate_strings(three_strings, "_MCS_930.dat", latticesize, p, NOR); concatenate_strings(three_strings2, "_NC_930.dat", latticesize, p, NOR); concatenate_strings(three_strings3, "_m(t)_930.dat", latticesize, p, NOR); output_MCS = fopen(three_strings, "a+"); /*naming the MCS information file*/ output = fopen(three_strings2, "a+"); /*naming the E(x,L) information file.*/ output_m = fopen(three_strings3, "a+"); free(three_strings); free(three_strings2); free(three_strings3); if ((output_m == NULL) || (output_MCS == NULL) || (output == NULL)) printf("error starts here\n"); }