我想编写一个代码来替换字符串中的单词而不使用字符串函数 [英] I want to write a code which replace words from string without use of string function
问题描述
全部。
我想编写一个代码来替换string中的单词。不使用字符串函数
示例str = 这是字符串删除是来自字符串并替换为was。
所以,最后str ="这是字符串。
Void replace(char * str,char * pattern1,char * pattern2)。
提前致谢。
Kin Parmar。
HI All.
I want to write a code which replace words from string.without use of string function
Example str = "This is string" remove "is" from string and replace with "was".
so, finally str = "This was string".
Void replace ( char * str , char * pattern1, char * pattern2).
Thanks in advance.
Kin Parmar.
推荐答案
HI All。
我想编写一个代码来替换string.without使用字符串函数的单词
示例str ="这是字符串"删除是来自字符串并替换为was。
所以,最后str ="这是字符串。
Void replace(char * str,char * pattern1,char * pattern2)。
提前致谢。
Kin Parmar。
HI All.
I want to write a code which replace words from string.without use of string function
Example str = "This is string" remove "is" from string and replace with "was".
so, finally str = "This was string".
Void replace ( char * str , char * pattern1, char * pattern2).
Thanks in advance.
Kin Parmar.
好的,到目前为止你做了什么?
请询问有关sepcifice的问题,如果你有问题,请阅读发布指南还没有。
Savage
Ok,what have u done so far?
Please ask about a sepcifice quesution and please read posting guidelines if u haven''t already.
Savage
好的,到目前为止你做了什么?
请询问有关sepcifice质疑的问题,如果你还没有,请阅读发布指南。
Savage
Ok,what have u done so far?
Please ask about a sepcifice quesution and please read posting guidelines if u haven''t already.
Savage
我想从字符串中找出单词并用新单词替换。
就像明智一样,我有字符串"伟大的人在这里从那个替换人并把男人。
我在这里写简单的代码: -
但需要帮助: -
I want to find out word from string and replace with new word.
like wise, I have string " Great People here" from that replace "People" and put "Man".
I write simple code here :-
but need help :-
我想从字符串中找出单词并用新单词替换。
就像明智一样,我有字符串伟大的人在这里从那个替换人并把男人。
我在这里写简单的代码: -
但需要帮助: -
char * str ="这是字符串" ;;
char * pattern1 ="是" ;;
char * pattern2 =" was" ;;
int slen = strlen(str);
for(int i = 0; i< slen; i ++)
{
for(int j = 0; j< slen; j ++)
{
if(pattern1 [i] == str [ j])
{
// str [j] = pattern2 [i]; ///在这里需要帮助,如何替换字符串。
}
}
}
I want to find out word from string and replace with new word.
like wise, I have string " Great People here" from that replace "People" and put "Man".
I write simple code here :-
but need help :-
char* str = "this is string";
char* pattern1 = "is";
char* pattern2 = "was";
int slen = strlen(str);
for (int i = 0; i <slen; i++)
{
for (int j =0; j < slen; j++)
{
if (pattern1[i] == str[j] )
{
//str[j]=pattern2[i]; /// Want help here, how to replace string.
}
}
}
为了做你想做的事,你必须先将你的字符串标记,然后用空格作为代币。
例如
string ="这是一个字符串
标记化后的
string1->"这个
string2->"""
string3->" a"
string4->" string"
我想你不想用字符串函数来标记化吗?
>
Savage
In order to do what u want to do,u must first tokenize ur string,uisng a whitespace as a token.
e.g
string="This is a string"
after tokenizingL
string1->"This"
string2->"is"
string3->"a"
string4->"string"
I suppose u don''t want to use string function to tokenize?
Savage
这篇关于我想编写一个代码来替换字符串中的单词而不使用字符串函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!