0

I'm very new to C++ and I'm trying to use SQLite3.h to access a database that is pre-filled. I added the database file (.db) to resources, placed it in same folder as project and added "sqqlite3.h" to header file folder.In the main .cpp file, I included just the following line.

#include "MyDatabase.db"

I'm getting several errors such as below.

1>------ Build started: Project: SQLiteLibrary, Configuration: Debug Win32 ------
LibNew.cpp
error C2146: syntax error : missing ';' before identifier 'format'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ';' before 'constant'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2018: unknown character '0x4'
error C2018: unknown character '0x1'
error C2018: unknown character '0x1'
error C2018: unknown character '0x40'
error C2018: unknown character '0x6'
error C2018: unknown character '0xe'
error C2018: unknown character '0x4'
error C2018: unknown character '0x2'
error C2018: unknown character '0x6'
error C3872: '0x4': this character is not allowed in an identifier
error C2018: unknown character '0x5'
error C2018: unknown character '0x4'
error C2018: unknown character '0x3'
error C2018: unknown character '0x1d'
error C2018: unknown character '0x3'
error C2018: unknown character '0x3'
error C2018: unknown character '0x3'
error C2018: unknown character '0x3'
error C2018: unknown character '0x7'
error C2018: unknown character '0x7'
error C2018: unknown character '0x1'
fatal error C1004: unexpected end-of-file found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Before these errors there is the location for database file. It seems its trying to read the .db file and showing errors.

Is there a way to include the database as a resource without C++ trying to read it. (All the information in .db file is in tables. So I'm curious about how C++ is able to read anything at all).

1 Answers1

1

MyDatabase.db is not a library. You must use include to import .h header files to your .cpp program only.

Here , here , here and here you can find some methods to work with sqlite databases in C/C++.

Community
  • 1
  • 1
Ebrahim Ghasemi
  • 5,850
  • 10
  • 52
  • 113