This is my code and when I run it, I am getting segmentation fault.
char *s = NULL;
s = (char *)malloc(5*sizeof(char));
s[0]='10';
s[1]='20';
printf("%s",s[1]);
please tell where the error is and why this is happening. My intension of the program is to dynamically create a string, give it some value byte by byte and print the values byte by byte.
Is there any way to add integer values to string. Because, I have a situation where length of string is to be in first part of string followed by data. Kindly suggest any method to do this in C.