This is just out of curiosity! Does anyone know what is the maximum number of characters that a line of code can have?

EDIT: Added more details.

Is it possibly possible to make two lines become one? .... This seems pretty odd, I dont know how to explain it, but maybe an example would be useful:
Suppose I have the following piece of code

#define A cout << "Hello,"
  << "world";

It obviously would not be syntactically legal to do something like that.
But, of course

#define A cout << "Hello World";

would do! So back to the question, is there any possible way to "connect" two lines of code and make them become one?

That is perfectly legal. For example:

cout << "This " <<
        "is " <<
        "a " <<
        "valid " <<
        "statement " <<
        endl;

Whitespace is ignored, so \n, SPACE, and TAB can be used most anywhere.

[EDIT]
Looked at your post again and missed the #define.... You're right. But if the line ends in \ it's OK:

#define O cout << "This " << \
        "is " << \
        "a " << \
        "valid " << \
        "statement " << \
        endl;

[EDIT]

Its very important that the \ is the very last character on the line and is not followed by comments or any white space.

If it is you will get some very unhelpful compiler errors especially if it is just a stray space some visually the code looks correct.

Know your keyboard shortcut for you editor to show white space.

Or if you'd like to connect two variable strings use "append"

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    string one = "Hello ";
    string two = "world!";
    one.append(two);
    cout << one << endl;
}

The above would ouput:

Hello world!
commented: answer has absolutely nothing to do with the question. -2

Its very important that the \ is the very last character on the line and is not followed by comments or any white space.

If it is you will get some very unhelpful compiler errors especially if it is just a stray space some visually the code looks correct.

Know your keyboard shortcut for you editor to show white space.

Wow, I just tried that! And it actually works!!!! ... Thanks~!

Its very important that the \ is the very last character on the line and is not followed by comments or any white space.

If it is you will get some very unhelpful compiler errors especially if it is just a stray space some visually the code looks correct.

Know your keyboard shortcut for you editor to show white space.

By the way, do you happen to know if this kind of syntax work in Java, too? If not, is there any equivalent methodology to this in Java?

I know nothing about Java except that most C++ programmers tend to underestimate how efficient it can be. I suggest you ask in the Java forum.

By the way, do you happen to know if this kind of syntax work in Java, too? If not, is there any equivalent methodology to this in Java?

Java doesn't need it because Java doesn't have a preprocessor like C++. :) the line continuation rules in Java for normal statements work without a special character.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.