From 4b4c6d20853b7b46cb52aeb7e6fe7fe801d9e7a5 Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Tue, 6 Nov 2018 10:21:04 +0100 Subject: [PATCH] Added compilation of StringExample. --- src/Examples/CMakeLists.txt | 4 ++++ src/Examples/StringExample.cpp | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Examples/CMakeLists.txt b/src/Examples/CMakeLists.txt index 8fcc4a5de7..3050205871 100644 --- a/src/Examples/CMakeLists.txt +++ b/src/Examples/CMakeLists.txt @@ -17,3 +17,7 @@ add_subdirectory( flow-vl ) #add_subdirectory( hamilton-jacobi-parallel-map ) #add_subdirectory( fast-sweeping-map ) #add_subdirectory( narrow-band ) + + +ADD_EXECUTABLE( StringExample StringExample.cpp ) +target_link_libraries( StringExample tnl ) \ No newline at end of file diff --git a/src/Examples/StringExample.cpp b/src/Examples/StringExample.cpp index f33da1392c..d6c45dee82 100644 --- a/src/Examples/StringExample.cpp +++ b/src/Examples/StringExample.cpp @@ -1,8 +1,10 @@ #include <iostream> +#include <TNL/String.h> -using namespace TNL +using namespace TNL; +using namespace std; -int main() +int main( int argc, char* argv[] ) { // constructors String str1; @@ -16,23 +18,24 @@ int main() cout << "str4:" << str4 << endl; // functions - int size = str3.getSize(); + /*int size = str3.getSize(); cout << "size of string:" << size << "bytes" << endl; int alloc_size = str3.getAllocatedSize(); cout << "alloc_size:" << alloc_size << endl; - int memory = str1.setSize( 256 ); - cout << "memory:" << memory << endl; + str1.setSize( 256 ); + size = str3.getSize(); + cout << "size of string:" << size << "bytes" << endl;*/ String str setter = str.setString( "Something new" ); cout << "setter:" << setter << endl; - int getter = str4.getString(); + const char* getter = str4.getString(); cout << "getter:" << getter << endl; - String word( computer ) ; + String word( "computer" ) ; third_letter = word[2]; cout << "third_letter:" << third_letter << endl; -- GitLab