All pastes #455238 Raw Edit

Someone

public c v1 · immutable
·published 2007-04-24 02:21 UTC
rendered paste body
#include <stdio.h>#include <string.h>#include <stdlib.h>void copyAndCombine(char* src1, char* src2, char* dest);int main(){  int total = 255 + 255 + 1;  char* destination = (char*) malloc(sizeof(char) * total);  int i;  char string1[255], string2[255];  //Asks user to input.  printf("First Input: %s", string1);  scanf("%s", string1);  printf("Second Input: %s", string2);  scanf("%s", string2);  copyAndCombine(string1, string2, destination);  printf("Output: ");  for (i = 0; i < total; i++){  printf("%c", destination[i]);//Prints combined words with space.    }  free(destination);  return 0;}//Function combines both words(strings) with a space in betweenvoid copyAndCombine(char* src1, char* src2, char* dest){  int i, length, string1, string2;  //Finds character length of each string array.  length = strlen(dest);  string1 = strlen(src1);  string2 = strlen(src2);  for (i = 0; i < length - 1; i++){    if ( i < (string1 - 1)){      dest[i] = src1[i];    //  printf("%s", dest[i]);    }    else if ( i == string1){      dest[i] = ' ';    //  printf("%s", dest[i]);    }    else if ( i < (string1 + string2 + 2)){      dest[i] = src2[i];    }   //   printf("%s", dest[i]);    else if (i = (string1 + string2 + 2)){      break;    }  }}