{ Snipperize } /C++

C++ snippets

Here are the latest C++ snippets. Please choose your favorite one or add a new one.

Image to colortext(html) converter

It converts any image to colored text (html). In order to compile textimg you will need to install magick++ dev libraries.

C++ / magick++, image, text / by ThePeppersStudio (105 days, 1.81 hours ago)

TimerObject

;====================== /* Timers Usage ____________________________________ **Place the following line at the top of your .iss file #include "${LavishScript.CurrentDirectory}/Scripts/vg_objects/Obj_Timers.iss" **In your script call the following object with these commands, or type this in the console Timers Methods(Things you can do) obj_timer:Add["Name of Timer" "Time in 1/10 Seconds"] obj_timer:Remove[Name of Timer] obj_timer:ClearAllTimers Timers Members(Things you can question of Timers) obj_timer.TimeRemaining["Name of Timer"] Notes ____________________________________ ** You dont need to know how an object works to use it. ** Objects are bits of code that perform specific functions. ** This function specifically Creates Timers for you ** You should clear all timers at the beginning and end of your script Credits ____________________________________ * Created by mmoaddict * Special Thanks to Amadeus and Lax for all their work */

C++ / timer, object, obj_timer / by ThePeppersStudio (122 days, 3.25 hours ago)

Check if a file exists

Check if a file exists use fstream.

C++ / file, fstream, exist / by ThePeppersStudio (141 days, 5.78 hours ago)

in-place stream formatting

void f( std::string const & ); void g( const char* ); f( make_string() << "Say hi" ); // works ok g( make_string() << "Bye" ); // kills the application g( (make_string() << "Hi again").c_str() ); // ok again std::string temporary is alive until g() returns

C++ / make_string, string, cstring, iostream / by ThePeppersStudio (142 days, 1.63 hours ago)

Fastest vs Easiest way to read a full file into a std::string.

Fastest vs Easiest way to read a full file into a std::string.

C++ / fastest, easiest, iostream, string, file / by ThePeppersStudio (142 days, 1.73 hours ago)

Useful debugging

It uses variadic macros.(http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html)

C++ / debug, variadic macros / by ThePeppersStudio (142 days, 1.81 hours ago)

Get the number of elements in an array

0[arr] is identical to arr[0] for arrays but will intentionally fail if it's used against a C++ object that overloads operator[] The C++ version is less intuitive but more type-safe

C++ / array, sizeof / by ThePeppersStudio (142 days, 1.84 hours ago)

C++ NULL Define

How to define NULL in C++.

C++ / define, NULL / by ThePeppersStudio (227 days, 3.49 hours ago)

Foreach in C++

define foreach in c++

C++ / foreach, define / by ThePeppersStudio (227 days, 3.54 hours ago)

Trim Function for String in C++

The main() is just for testing the function, let's see how it went. $ gcc -Wall -o go trim.c $ ./go s = 'srikanth s' empty = '' newline = '' double_newline = '' single_char = 's' This function doesn't create a new char[] for the trimmed string, it modifies the original. Let me know if you've got an optimized version than this, I'll be interested to learn.

C++ / trim, string / by ThePeppersStudio (227 days, 3.61 hours ago)