Hello, It has been awhile since I have posted here since I have been horribly without computer for awhile now. Anyways, I was wondering if anybody knew where to find, or could make up, a lorem ipsum in C++. What I mean is that Lorem Ipsum makes a good filler text for websites and brochures, but what if you wanted filler C++ code instead? Does anybody know where I could find such a thing?

4 Years
Discussion Span
Last Post by Labdabeta

What is your intent for this? Usually, with C++ we use stubbed methods that return some meaningful, but not critical, value when called, so that the program can flow as indended. As for tools that do this, I am not aware of any, though they may exist.


Lorem Ipsum for C++? That's odd. What exactly is there to fill? The point of a Lorem Ipsum (as I understand it) is that the content is of no concern (and thus, the randomly-generated latin-looking words), but only the formatting is important. In programming, that seems pretty inappropriate, mostly because form and content are so tightly coupled. In programming, the form is the means to express the content, they can hardly be separated. In document writing (or similar texts), there is a clear separation between the content (raw text, and titles of article or sections) and how they are formatted to the paper. A good example of that is LaTeX in which the two are (almost) completely separated. In this case, it is easy to use a filler for the content while setting all the formatting.

If all you are talking about is filler names and stuff to illustrate design patterns and stuff, then there are a few classic "Lorem Ipsum", in particular "Foo", "Bar", "MyClass", "doSomething()", 42, 69, or std::cout << "Hello World!" << std::endl;. I use those quite a bit on this forum. You cannot illustrate a particular form (like an idiom or a design pattern) without giving somewhat meaningful names to the functions and classes involed.

If you are talking about code stubs, like the ones generated by an IDE (when you click on a menu button like "New Class.."), then you don't really need to fill anything, just put in the C++ keywords.

If you are talking about illustrating a particular coding style (indentation, brace-placements, naming convention, etc.), then, again, you will need some fillers, but not anywhere near the amount of filler that would require randomly generating fake code.

Can you elaborate on the purpose of this?


In a lot of computer-oriented movies, they'll put random code scrolling on the computer monitors or as part of a montage during the credits. I've also seen a screensaver do something such as this, where a near-infinite amount of text that LOOKS to be in C/C++ style syntax needs to be generated, and it can't look ridiculously repetitive even though it doesn't need to necessarily have a function or even compile.


For that purpose, if it were me, I would probably just write a program that grabs the source files (or just headers) from either the standard library implementation (GCC) or some other open-source library like Boost, and grab random bits and pieces of it. Nothing is going to look better than that, as "random code".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.