All pastes #114625 Raw Edit

Untitled

public c v1 · immutable
·published 2006-08-04 03:47 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){  char *enc_string = NULL;  int i = 0;  int ch;   // change char to int    do{     if((enc_string = realloc(enc_string, (i+1) * 10 + 1)) == NULL)  // change 11 to 10 + 1     {                 printf("Memory allocation failure!");                 return 0;     }     fgets(enc_string+(i*10),11, stdin);     char *newline_pos = strchr(enc_string+(i*10),'\n');  // changed 11 to 10     i++;  } while(newline_pos == NULL);    enc_string[strcspn(enc_string, "\n")] = '\0';    //while ((ch = getchar()) != '\n' && ch != EOF);    printf("%s",enc_string);    printf("Press a key to continue!");  //getchar();	  system("PAUSE");  return 0;}