Okay i tried this
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
Your code does not use anything from said:
#include<assert.h>
#include<string.h>
char *f()
{
char *s = malloc(9);
assert(s != NULL);
strcpy(s,"good bye");
You don't return anything after telling the compiler that the function
returns a char * value. Place a
return s;
here.
}
int main(void)
{
printf("\n %s",*f()='A');
What are you trying to do here? The 's' format specifier expects a char
* argument and you are passing an int argument here. Character
constants are of type int in C.
Also because you do not return a sensible value from 'f' the compiler is
going to access some random garbage, invoking undefined behaviour.
Also another
return 0;
here.
}
but still i am getting segmentation fault
What are trying to do? Overwrite the string returned from 'f' with
another string literal? If so, do:
int main(void)
{
char *p;
p = f();
printf("%s\n", p);
free(p);
p = "A";
printf("%s\n", p);
return 0;
}
And _return_ _a_ _sensible_ _value_ from 'f'.