/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#define ROZ 2
int main()
{
char *napis;
int n=0;
char a;
napis=calloc(ROZ,sizeof(char));
printf("Witam w programie, który dynamicznie wpisuje znaki do tablicy!\n");
do
{
printf("Podaj znak o indeksie %d\n",n);
scanf(" %c",&a);
if(n<ROZ)
{
napis[n]=a;
}
else if(n>=ROZ)
{
napis=realloc(napis,(n+1)*sizeof(char));
napis[n]=a;
}
n++;
}while(a!='.');
napis=realloc(napis,(n+1)*sizeof(char));
napis[n]='\0';
printf("|");
for(n=0;napis[n]!='\0';n++)
{
printf("%c|", napis[n]);
}
return 0;
}