#include#include int main() { CPLString str = "Hello, World!"; const char* cStr = str.c_str(); std::cout << cStr << std::endl; return 0; }
#includeIn this example, we use the GDAL (Geospatial Data Abstraction Library) to open a TIFF file called "example.tif" and retrieve its projection using the GetProjectionRef() function. We store the projection in a CPLString variable called "projection" and use c_str() to get a C-style string representation of it, which we then print to the console using std::cout. The CPLString class is a part of the CPL library, which is included in the GDAL/OGR (Geospatial Data Abstraction Library/OpenGIS Simple Features Reference Implementation) library.#include int main() { const char* filename = "example.tif"; GDALDataset* dataset = (GDALDataset*) GDALOpen(filename, GA_ReadOnly); CPLString projection = dataset->GetProjectionRef(); const char* projection_cStr = projection.c_str(); std::cout << "Projection: " << projection_cStr << std::endl; GDALClose(dataset); return 0; }