C program to get SQLite version in Linux

Here, we are going to write a C language program to get SQLite version in Linux.
Submitted by Nidhi, on February 12, 2021

Prerequisites:

The following packages need to be installed in the ubuntu machine for Sqlite connectivity using the C program.

sudo apt install sqlite3
sudo apt install gcc
sudo apt install libsqlite3-dev

Problem Solution:

In this program, we will get the SQLite version using the sqlite3_version() function. The sqlite_version() function returns the string that contains the SQLite version.

Program/Source Code:

The source code to get the SQLite version is given below. The given program is compiled and executed successfully on Ubuntu 20.04.

//C program to get the installed version of sqlite.

#include <sqlite3.h>
#include <stdio.h>
#include <string.h>

int main(void)
{
    char ver[32];

    strcpy(ver, sqlite3_libversion());
    printf("Sqlite version: %s\n", ver);

    return 0;
}

Output:

$ gcc version.c -o version -lsqlite3 -std=c99
$ ./version
Sqlite version: 3.31.1

In the above program, we included the sqlite3.h header file to uses sqlite3_libversion() function. Here, we created a character array ver and then we copied the SQLite version to the ver variable and then we printed the SQLite version on the console screen.

C SQLite Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.