Skip to content

[StdLib] Add C3-native sscanf #2242

Open
@BWindey

Description

@BWindey

Libc provides the sscanf (and family) to parse a string from a format to some variables. Basically the exact opposite of printf.
As we have the C3 version of printf, it would also be great to have a C3 version of sscanf.

Example:

fn void main() {
	String seq = "\e[97;5u";
	int codepoint;
	int modifier;
	if (string::sscanf(seq, "\e[%d;%du", &codepoint, &modifier) == 2) {
		io::printfn("Parsed codepoint %d and modifier %d", codepoint, modifier);
	} else {
		io::eprintn("Failed to parse string");
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Discussion neededThis feature needs discussion to iron out detailsEnhancement RequestNew feature or requestStdlibStandard library issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions