Skip to content
Snippets Groups Projects

Proof: Call a function with missing parameters in C

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Martin Wölzer
    Edited
    example.c 408 B
    //file lib.c:
    #include<stdio.h>
    void test(int a, int b) {
        printf("%d, %d\n", a, b);
    }
    
    //file main.c:
    void test(int a); 
    int main() {
        test(128);
    }
    
    //compile with `gcc -c -o lib.o lib.c; gcc lib.o main.c -o main`
    
    //execute (each time we get a different output...):
    ./main 
    128, -1103440664
    
    ./main 
    128, 1346491064
    
    So we are there:
    https://raphlinus.github.io/assets/Anything_is_Possible_scaled.jpg
    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