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?

  • Flyberius [comrade/them]
    ·
    9 months ago

    I know shit all about c, but if I were to guess I would say 1. Because to be it is defining the signature of the function.

    I am an idiot though and you should disregard what I say because I do not C.