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" }
This is a discussion on Find text in quotes of string. within the C++ Programming forums, part of the General Programming Boards category; If a string held this: Code: name { "cube01" } What would be an efficient way to copy what's in ...
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)
-- Will you show me how to c++?
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";