#include #include #include "String.h" using ecci::String; //using namespace std; // mala practica de programacion void print_string(const char* description, const String& str) { std::cout << description << " = [" << str << ']' << std::endl; #if 0 if ( str.getLength() > 0 ) { size_t i = rand() % str.getLength(); std::cout << description << "[" << i << "] == " << str[i] << std::endl; } #endif } int main() { srand(time(nullptr)); String source = "myfile.txt"; // String source("myfile.txt"); // String source{"myfile.txt"}; // FILE* tempFile = fopen( source + ".temp", "r"); // FILE* tempFile = fopen( (const char*)(source + ".temp"), "r"); FILE* tempFile = fopen( (source + ".temp").c_str(), "r"); if ( ! tempFile ) std::cerr << "Could not open: " + source + ".temp" << std::endl; print_string("source", source); // * const_cast( source.c_str() ) = '-'; // std::cout << source.c_str() << std::endl; String s2; print_string("s2", s2); String s3 = source; print_string("s3", s3); s2 = s2; print_string("s2", s2); String temp = source + ".temp"; print_string("temp", temp); int error = 13; s2 = String("Error ") + error + ": No se pudo abrir " + temp; print_string("s2", s2); s2[4] = 'R'; print_string("s2", s2); #if 0 s2 = 3; print_string("s2", s2); #endif if ( s2 == s2 ) std::cout << " iguales\n"; size_t i = rand() % s2.getLength(); std::cout << "s2[" << i << "] == " << s2[i] << std::endl; // std::cout << temp; return 0; }