JameB 66 Junior Poster

Use the textcolor function (it's not standard compliant) from conio.h library:

#include <conio.h>
int main()
{
textcolor(RED);
cputs("Red text in console!");
return 0;
}

http://www.ousob.com/ng/borcpp/ng6c57c.php

try using google next time!!

JameB 66 Junior Poster

I think what you are asking is how add number as long as 100 000 digits.

I think the algorithm you are talking about is basically you developing a piece of code that adds just the way you would add two numbers on a piece of paper. For example, you would start from the last digit of the number (the last digit on the right) and you add them. If the sum of these two digits is bigger than 9 then you carry 1 else you just store the sum of the two digits. You then move one digit left and you repeat the same process while taking the carried digit in account. The end result would be the sum of these two number!!

You also need to take a look at these topic :

> ASCII values of the numbers
> loops
> reversing arrays
> Padding make them equal in length
> Adding and substracting using ASCII values

I can't think of any more but there may be problems that you'll have to get around.....

Salem commented: Bingo! +30
JameB 66 Junior Poster

Why do you have to do something that complicated??

Here is what I came up with!

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string y;
	char x;

	cout<<"Please enter a string: "<<endl;
	cin>>y;
	cout<<"Please enter a character: "<<endl;
	cin>>x;

	cout << endl << endl << endl;

	for(int i = 0; i < y.length(); i++)
	{
		if(y[i] == x)
		{
			cout << x << " found at " << i << '.' << endl;

			cout << "Replacing the " << y[i] << " with 'x'." << endl << endl << endl;
			y[i] = 'x';
		}
	}

	cout << "The final string is " << endl << y << endl;

	return 0;
}
Ancient Dragon commented: good simple solution :) +36