#include <stdio.h>
#define BUFFER_LEN 500
int main() {
char buffer[BUFFER_LEN];
char *pS[3] = { NULL };
char *pbuffer = buffer;
int i = 0;
for (i=0; i<3 ; i++)
{
printf("\nEnter a message\n");
*(pS + i) = pbuffer;
/* Get input till Enter pressed */
while ((*pbuffer++ = getchar()) != '\n');
*(pbuffer - 1) = '\0';
}
printf("\nThe strings you entered are:\n\n");
for(i = 0 ; i<3 ; i++)
printf("%s\n", *(pS+i));
printf("The buffer has %d characters unused.\n",&buffer[BUFFER_LEN - 1] - pbuffer + 1);
}
|