Dear All,
how to read read characters till white space
now I need pvar as rollnumber (read till white space)Code:char *a; a =(char *)malloc(15); strcpy(a, "rollnumber 449"); char *pvar,; pvar =(char *)malloc(10);
Thanks ...
Dear All,
how to read read characters till white space
now I need pvar as rollnumber (read till white space)Code:char *a; a =(char *)malloc(15); strcpy(a, "rollnumber 449"); char *pvar,; pvar =(char *)malloc(10);
Thanks ...
but your malloc is not big enough to store 10 chars + nul-char
1. scanf("%10s" should work
2. strchr + strncpy
3. strtok + strcpy
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
strtok() worked for me
Thanks ...