Find text in quotes of string.

If a string held this:
name { "cube01" }
What would be an efficient way to copy what's in the quotes to a new string?
what is name? std::string? char array?
string::copy in the string class

http://www.cplusplus.com/reference/string/string/

or cstring strcpy http://www.cplusplus.com/reference/clibrary/cstring/

string operator =

string str1 = "hello";
string str2;

str2 = str1;

cout << str2;

"hello"
Last edited on
I was able to use the find function to find the quote's position, and then use copy to copy the name.

1
2
3
4
5
6
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";
Topic archived. No new replies allowed.