you malloc() a limited buffer using strcat(), but if the string is longer than u allocated memory for fname, the buffer will not be big enough. use strncat, and calculate the remaining space for the strncat() appropriately every time .
u will not get any problem after this.always use strncat ,it solves memory problems.
User Profile
Collapse
-
this is the simple code:
char*s="char*s= %c%s%c;main(){p rintf(s,34,s,34 );}";main(){pri ntf(s,34,s,34); }...Leave a comment:
-
what is fname..???
have u allocated enough memory for fname..????
check once memory issues......Leave a comment:
-
hey man..its not home work problem..this question was asked in one of the interview..i know how to do with shift operator ..but i don't know how to do it without shift operator.Leave a comment:
-
how to swap
how to swap the 2 bytes..B1 and B2(16 bits)..without using shift operator. -
-
-
this code is to check the entries in the directory(eithe r current or any specified)...
in this code what i have to do is ..i have add the check to see wheather the name which is listed from this code is available in another directory called example d.ids..if name is available in that(d.ids) directory we have to continue...othe rwise we have to skip...Leave a comment:
-
how to write code...
char id_dir[PATH_MAX] = {0,};
strncpy(id_dir, a->id_file_name , PATH_MAX);
id_dir[PATH_MAX-1] = 0;
strncpy(id_dir, ".d/", PATH_MAX - strnlen(id_dir, PATH_MAX));
struct dirent *id_file = NULL;
do {
errno = 0;
dp = readdir(id_dir)
if (!dp)
break;
/* how add check here to ensure name ends in ".ids"(director y), skip if not. */
f = fopen(id_file,... -
hi man, i want to write code in c man..not GUI or running DOS commands.....Leave a comment:
-
how to solve this problem
In c i have to create new directory , i have to add the files to the directory and
we have to add this new directory to another old directory..plea se suggest any solution to this problem...
No activity results to display
Show More
Leave a comment: