a problem we couldnt fix...
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
char* saisit_chaine_sans_tampon()
{
int i,s;
char *q;
printf("Ecrivez une chaine de caractere-Pour sortir touche '1'");
(char*)realloc(q,(1*sizeof(char)));
*q='a';//je donne une valeur initialement,sinon il y une errruer
for(i=0;q[i-1]!='1';i++)
{
q[i]=getch();
s=i+1;
(char*)realloc(q,(s*sizeof(char)));
}
q[i-1]='\0';
return q;
free(q);
}
int main()
{
char *p;
p=saisit_chaine_sans_tampon();
printf("%s",p);
system("PAUSE");
return 0;
}
for compiler everything is allright but its not working.so couldnt get whats wrong please help me