Skip to content
Snippets Groups Projects

Stealth Fehler

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Erik Friesen
    main.c 664 B
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    
    int countIntInInteger(char* input){
        char* out;
        char* end = NULL;
        int value = strtol(input, &end, 10);
        out = malloc(value + strlen(input));  // could be shorter, but play it safe
    
        if(value == 0)
        {
            return value;
        }
        for (int i = 0; i != value; i++)
            {
                char c = end[i];
                if (c > 96 && c < 123) // ascii a-z
                {
                    c -= 32;
                }
                out[i] = c;
            }
        free(out);
        return value;
    }
    
    int main() {
        char test[1024];
        scanf("%[^\n]%*c", test);
        countIntInInteger(test);
        return 0;
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment