How to dynamically accept a string with spaces? I had tried gets()
, but it is not working, and I don't want to take input from file. I want to accept a string without specifying string size.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *accept()
{
char *s;
s = (char *)malloc(sizeof(char));
gets(s);
return s;
}
int main()
{
char *str;
printf("\nEnter`enter code here` one string");
str = accept();
}