I am actually trying to make use of this method Travels to extract information out However I have problems doing it, I hope you guys will be able to help me out I have problems trying to extract a string in between of " ", for eg "hello" to extract the hello. These are my methods below.
旅行方法
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;
}
在我的读法中( 我将显示部分方法)
//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"