我实际上正在尝试使用这种方法 Travels 来提取信息但是我在这样做时遇到了问题,我希望你们能够帮助我我在尝试提取“”之间的字符串时遇到问题,例如“你好”提取你好。这些是我下面的方法。
游记法
char *Travels(char Destination, char *originPtr)
{
do
{
originPtr++;
}while (*originPtr != Destination);
originPtr++;
return originPtr;
}
在我的主要
int main()
{
//pointer for reading of file
char *startPtr1;
char Lines[256];
//read file and perform
ifstream chordfile("myfile.txt");
if (chordfile.is_open())
{
do
{
chordfile.getline(Lines, 256);
startPtr1 = Lines;
readFileInput(startPtr1);
}while(chordfile.eof() == false);
chordfile.close();
}
return 0;
}
在我的 readFileInput 方法中(我将展示部分方法)
//if it is insert.
if (strcmp(Stringg, "insert") == 0)
{
char *SpecialPtr1;
currentPtr1=Travels(' ',startPtr1); // travels to Insert(*) 7 "your_data"
int insertPeerNum = (int)atoi(currentPtr1); // travels to Insert (7) "your_data"
currentPtr1=Travels(' ',currentPtr1); // travels to Insert 7(*)"your_data"
currentPtr1=Travels('"',currentPtr1);
SpecialPtr1=Travels('"',currentPtr1);
*******this is the area which I am actually stucked at**********
}
在文本文件中
Insert 7 "your_data"
Insert 7 "hello"