Trim leading whitespace

    0

    1

    Giovanny Gongora

    Codiga's C Recipes

    Whitespace is defined by isspace(). Returns a pointer into s, at the address of the first non-whitespace character. This should not be passed to free().

    #include <string.h>
    #include <ctype.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    const char *
    ltrim(const char *s) {
    	while (isspace((unsigned char) *s)) {
    		s++;
    	}
    	return s;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.