All pastes #455248 Raw Edit

Stuff

public c v1 · immutable
·published 2007-04-24 02:28 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>void copyAndCombine(char* src1, char* src2, char* dest);int main(){  int stringLength = (255*2)+1;  // Above allocate enough space for 2x Strings and one space  char* out = (char*)malloc(sizeof(char) * stringLength);  char string1[255];  char string2[255];  printf("Enter String 1:");  scanf("%s", string1);  printf("Enger String 2:");  scanf("%s", string2);  copyAndCombine(string1, string2, out);  printf("Here is your string: %s\n", out);  free(out);  return 0;}void copyAndCombine(char* src1, char* src2, char* dest){  int i,j,loc=0;  for(i=0; src1[i]!='\0'; i++) { // Add first string to destination    dest[i]=src1[i];    loc += 1;  }  dest[loc]=' '; // Add space to destination  loc++;  for(j=0; src2[j]!='\0'; j++) { // Add second string to destination    dest[loc+j]=src2[j];  }  dest[loc+j]='\0'; // Finish with a space}