I have a C program that reads from keyboard, like this:
scanf("%*[ \t\n]\"%[^A-Za-z]%[^\"]\"", ps1, ps2);
For a better understanding of what this instruction does, let's split the format string as follows:
%*[ \t\n]\"
=> read all spaces, tabs and newlines ([ \t\n]
) but not store them in any variable (hence the '*
'), and will keep reading until encounter a double quote (\"
), however the double quote is not input.
Once scanf()
has found the double quote, reads all caracters that are not letters into ps1. This is accomplished with...
%[^A-Za-z]
=> input anything not an uppercase letter 'A' through 'Z' and lowercase letter 'a' through 'z'.
%[^\"]\"
=> read all remaining characters up to, but not including a double quote into ps2 ([^\"]
) and the string must end with a double quote (\"
), however the double quote is not input.
Can someone show me how to do the same thing in C++
Thank you