FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


C++





AhmedSalmanJamal
Is this code valid? Why or why not?

Code:
void Ex1_2()
{
    const string exclam = "!";
    const string message1 = "Hello" + " World" + exclam;
    cout << message1 << endl;
}
Sebaci
It is valid, why are you asking about it here, just check it yourself by compiling the code
AhmedSalmanJamal
Sebaci wrote:
It is valid, why are you asking about it here, just check it yourself by compiling the code


My dear friend... although a solution to a problem looks very trivial... mankind always makes a mistake by overlooking or under estimating the simplest mistakes Smile The above program is not valid and you can actually try and compile it yourself... if you wish you could also correct the mistake in the code Smile I hope you don't take my gesture as a sign of rudeness but an aura of friendly wisdom ... Smile
Sebaci
My code:

Code:

#include <cstdlib>
#include <iostream>

using namespace std;
void Ex1_2();
int main(int argc, char *argv[])
{
    Ex1_2();
    system("PAUSE");
    return EXIT_SUCCESS;
}

void Ex1_2()
    {
    const string exclam = "!";
    const string message1 = "Hello" " World"+exclam;
    cout << message1 << endl;
    }


OR:
Code:

#include <cstdlib>
#include <iostream>

using namespace std;
void Ex1_2();
int main(int argc, char *argv[])
{
    Ex1_2();
    system("PAUSE");
    return EXIT_SUCCESS;
}

void Ex1_2()
    {
    const string exclam = "!";
    const string message1 = "Hello World"+exclam;
    cout << message1 << endl;
    }


so we shouldn't connect the words with "+" in string Smile
AhmedSalmanJamal
Sebaci wrote:
My code:

Code:

#include <cstdlib>
#include <iostream>

using namespace std;
void Ex1_2();
int main(int argc, char *argv[])
{
    Ex1_2();
    system("PAUSE");
    return EXIT_SUCCESS;
}

void Ex1_2()
    {
    const string exclam = "!";
    const string message1 = "Hello" " World"+exclam;
    cout << message1 << endl;
    }


OR:
Code:

#include <cstdlib>
#include <iostream>

using namespace std;
void Ex1_2();
int main(int argc, char *argv[])
{
    Ex1_2();
    system("PAUSE");
    return EXIT_SUCCESS;
}

void Ex1_2()
    {
    const string exclam = "!";
    const string message1 = "Hello World"+exclam;
    cout << message1 << endl;
    }


so we shouldn't connect the words with "+" in string Smile


Very well said! Words from a true genious Very Happy
Related topics
Command and Conquer
Funny C variable
What can I do with C-Panel?
HELP ME in C++
Languages in c++
C++ TUTORIAL : INTRODUCTION TO C++
I searching for a site
Image Processing in C++ by Shirish
C en C++
C# tutorials
C en C++
C#,Visual Basic.NET,Visual Studio.NET Videos
[Question] Visual Basic C++, PHP, mySQL language guides...
et un appart sur Paris pour septembre, c'est possible ?
My site : www.sunsoft.c-o.in
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.