QP School

Full Version: Linking external libraries in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To use functions from external libraries, you need to link them during the compilation process.

// Compile with math library
// gcc main.c -lm -o main
#include <stdio.h>
#include <math.h>

int main() {
    double result = pow(2, 3);
    printf("2^3 = %.2f\n", result); // Output: 2^3 = 8.00
    return 0;
}