Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore whitespace after scan? #128

Open
ikspress opened this issue Oct 2, 2024 · 0 comments
Open

How to ignore whitespace after scan? #128

ikspress opened this issue Oct 2, 2024 · 0 comments

Comments

@ikspress
Copy link

ikspress commented Oct 2, 2024

#include <cstdio>
#include <exception>
#include <fmt/base.h>
#include <scn/scan.h>
#include <string>

int main() try {
    fmt::println("{}", scn::scan<std::string>(stdin, "{:[^\n]}")->value());
    auto result = scn::scan<std::string>(stdin, "{:[^\n]}");
    if (result)
        fmt::println("{}", result->value());
    else
        fmt::println("{}", result.error().msg());
} catch (std::exception const &e) {
    fmt::println(stderr, "{}", e.what());
    return 1;
}

I tried to read a line of text from console, but it fails due to a residue \n.

Hello, world!
Hello, world!
No characters matched in [character set]

Is there any way to ignore all whitespace characters before read?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant