Hi everyone,
I have not done C++ for quite sometime now and seems that i may have forgotten a bit so please bear with me a while.
I am currently trying to output some text to the console in c++, but seems i may have forgotten something because the text does not output correctly. It is incorrect because each time there is a space in the string only the first string is printed to the console.
This is the code
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <strings.h>
#include <stdio.h>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
string a;
string b = "This is a test string";
int c = 0, d = 0;
cout<< "Input a string\n";
cin>> a;
cout<<endl;
d = a.compare(b);
if(d == 0)
{
cout<< "Both the strings are the same\n";
cout<< "The below is string a\n";
//The below is where the problem occurs if the string is
//the same and only the word "This" is printed
//to the console
cout<< a
cout<< "\n";
cout<< "The below is string b\n";
cout<< b;
cout<< "\n";
}
else
{
cout<< "Both the the strings are different\n";
cout<< "The below is string a\n";
cout<< a;
cout<< "\n";
cout<< "The below is string b\n";
cout<< b;
cout<< "\n";
}
cout<<endl;
system("PAUSE");
return 0;
}
I am currently using DevC++.
Looks like i have become a bit rusty, please bear with me on this question.
Any help is greatly appreciated
Thank You
Yours Sincerely
Richard West