Sorry, forgot to mention, please ignore the log statements (just debugging tools). And also, even if I call strncpy(result, input_str, 20) it copies 20 characters, then adds funny characters after that. > I tried to resist the temptation of going to the group for help, but > after another full day of banging my head against the computer desk, I > caved in. > I am trying to delete a certain line from the room description and this > line is usually at the end of the description. It works fine except for > the fact that > the final room description has an unusual character repeated like twenty > times at the end. This only happens whenever I use strncpy. > > PS: I am using MSVC++ under W2K. > > Please find a cure for my splitting headache. Thanks :) > > > char input_str[MAX_INPUT_LENGTH], *tmp2, result[MAX_INPUT_LENGTH]; > > if (full_ex) { > log("world descript: %s\r\n", world[room].description); > strcpy(input_str, world[room].description); > log("input_str = %s\r\n", input_str); > tmp2 = strstr(input_str, "There is a huge gaping hole in the > ground!\r\n"); > > if (tmp2 != NULL) { > log("tmp2 = %s", tmp2); > log("strlen of input_str: %d\r\n", strlen(input_str)); > log("input_str inside: %s\r\n", input_str); > strncpy(result, input_str, strlen(input_str) - strlen(tmp2)); > log("result: %s\r\n", result); > free(world[room].description); > world[room].description = str_dup(result); > } > } -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/24/03 PDT