Hi below is the simple c code.
output : ptr = jyoti ranjanCode:#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char const*ptr; ptr = malloc(sizeof(char) * 4); strcpy(ptr,"jyoti ranjan"); printf("ptr = %s\n",ptr); return 0; }
above everything is fine.
but is there any way by which malloc can only give 4 byte only.
i.e ptr should not able to take more than 4 charecters.
Regards
jyoti ranjan panda