If a string held this:
What would be an efficient way to copy what's in the quotes to a new string?Code:name { "cube01" }
Printable View
If a string held this:
What would be an efficient way to copy what's in the quotes to a new string?Code:name { "cube01" }
strcpy(char *dest, const char *source)
once you locate the first quote, iterate through the string until you find the last one.
Thanks.
I was able to use the find function to find the quote's position, and then use copy to copy the name.
Code:tester="\"";
findPos=line.find(tester); //finds first quote mark
findPos2=line.find(tester, findPos+1); //finds second quote mark
length=line.copy(name, (findPos2-findPos-1), findPos+1); //copies the name into name
name[length]='\0'; //end it off
cout<<"Name: "<<name<<"\n";