In the snippet below:

#include <stdio.h>

void swap (int*, int*);
// ^----(1)

int main (void) {
    int a = 21;
    int b = 17;

    swap(&a, &b);
    printf("a = %d, b = %d\n", a, b);
    return 0;
}

void swap (int *pa, int *pb) {
// ^----(2)
    int t = *pa;
    *pa = *pb;
    *pb = t;
    return;
}

Which of these between (1) and (2) can be considered as a function prototype?

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    8 months ago

    Is it called a prototype in C? I’ve always known them as definitions/declarations and sometimes referred to as “headers” because they’re usually defined in header files.