Создать форум бесплатно: ixbb.ru :: Календарь на Июнь 2024 года: calendar2008.ru/2024/iyun/

  Reply to this topicStart new topic

Замена символов в строке на Си.

, Help :D
Отправлено: May 30 2010, 10:46 AM
Quote Post


Группа: Members
Сообщений: 245
Пользователь №: 1942
15-October 08

Всем привет, короче говоря, вот код:

char *str_replace(char *str1, char *str2, char *str6)
 char *str4;
 char *str5=malloc(0);

 while(strstr(str6, str1)) {
   str4 = strstr(str6, str1);
   strncpy(str5 + strlen(str5), str6, str4 - str6);
   strcat(str5, str2);
   str4 += strlen(str1);
   str6 = str4;
 return strcat(str5, str4);

char *htmldecode(char *str)
 str = str_replace("!", "!", str);
 str = str_replace(""", "\"", str);
 str = str_replace("#", "#", str);
 str = str_replace("$", "$", str);
 str = str_replace("%", "%", str);
 str = str_replace("&", "&", str);
 str = str_replace("'", "'", str);
 str = str_replace("(", "(", str);
 str = str_replace(")", ")", str);
 str = str_replace("*", "*", str);
 str = str_replace("+", "+", str);
 str = str_replace(",", ",", str);
 str = str_replace("-", "-", str);
 str = str_replace(".", ".", str);
 str = str_replace("/", "/", str);
 str = str_replace(":", ":", str);
 str = str_replace("&#59,", ";", str);
 str = str_replace("<", "<", str);
 str = str_replace("=", "=", str);
 str = str_replace("&62;", ">", str);
 str = str_replace("?", "?", str);
 str = str_replace("@", "@", str);
 str = str_replace("[", "[", str);
 str = str_replace("\", "\\", str);
 str = str_replace("]", "]", str);
 str = str_replace("^", "^", str);
 str = str_replace("_", "_", str);
 str = str_replace("`", "`", str);
 str = str_replace("{", "{", str);
 str = str_replace("|", "|", str);
 str = str_replace("}", "}", str);
 str = str_replace("~", "~", str);
 return (str);

При компиляции выдает ошибку, связанную с функцией malloc(0).

Суть вопроса: как можно написать подобное решение как можно проще и как можно производительнее?

P.S. на str = str_replace("~", "~", str); особого внимания не обращайте, это всё форум запорол, там html'овские ascii символы в начале biggrin.gif

98% ошибок системы находятся в полуметре от монитора....
PMEmail PosterUsers WebsiteICQ
Отправлено: May 30 2010, 12:44 PM
Quote Post

  Команда ЭйсВэб

Группа: Super moderator
Сообщений: 940
Пользователь №: 508
30-March 07

C C++ давное не работал, но помоему там есть стандартная функция замены символов. Погугли, что бы не изобретать велосипед.

PMEmail PosterICQAOL
Отправлено: Dec 7 2013, 01:22 PM
Quote Post


Very best Across the style and design team discussed my family room<br><br>within the very best affordable. Starting with lighting fixtures, that they picked the Fillista necklace light Canada Goose as a result of IKEA $29. 99, moved by a further middle century advanced old classic the main Henningsen Artichoke rug pertaining to Poulsen Discount Moncler. Our goal is to renovation as well as relax the very middle century seem create it again exciting. Your property possesses a retro the kitchen area and we needed to Nike Air Max always keep a few of that will feeling within the space. And also there's a young lad while in the relatives so we had to keeping it exciting, spelled out Turner.<br>
Best Across the style and design workforce attended to my tv room
Top notch Throughout the design and style squad sorted out everyone in the room
Often the nook calculated high threshold xxxxxx
Отправлено: Dec 13 2013, 04:35 AM
Quote Post


Which requires they revealed little ones by a variety of<br><br>years movies about equal sexual husbands and wives suggesting to each other and gauging typically the allergic reactions and also reactions in the boy followers. Canada Goose Parka It really is appeared to be beautiful to enjoy your upcoming versions generating adult as well as new responses Womens Prada Handbags, a product you possessed hardly ever get with the comment sections of most of these article content. However Men Moncler most of the reviews and also problems lifted by just Benny and even Rafi Okay experienced us planning<br>
shown the total straight-forward stop this time around
In which many people exhibited kids out of many
broadcast the full frank stunt this time around tttttt
Отправлено: Feb 6 2014, 08:13 PM
Quote Post


Группа: Members
Сообщений: 69
Пользователь №: 5045
6-February 14


PMEmail PosterUsers Website

Topic Options Reply to this topicStart new topic


[ Script Execution time: 0.0304 ]   [ 10 queries used ]   [ GZIP выключен ]