.......1234
.....*1234
-------------
.......4936
.....3702
...2468
.1234
-------------
.1522756

Not sure if I understood that format properly...

#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS//to remove some annoying warnings my compiler keeps generating
#include <iostream>
using namespace std;

void output(const char * output)
//you might want to change this
{
	cout<<output<<endl;
}

void multiply_frmt(int num1, int num2, int width)
//num1 and num2 are the two values to multiply it with
//width is how wide a line is. MUST BE WIDE ENOUGH OR A BUFFER WILL OVERFLOW.
{
	char thisLine[32];//change these numbers if needed (I don't think it should)
	char theDots[32];
	char theSpaces[32];
	char theNumbers[8];//you shouldn't need more than eight digit numbers... right?
	sprintf(thisLine, "%i", num1);
	for (int i=0;i<width;i++) theDots[i]='.';
	theDots[width]=0;
	strcpy(theDots+width-strlen(thisLine), thisLine);
	output(theDots);
	sprintf(thisLine, "*%i", num2);
	for (int i=0;i<width;i++) theDots[i]='.';
	theDots[width]=0;
	strcpy(theDots+width-strlen(thisLine), thisLine);
	output(theDots);

	for (int i=0;i<width;i++) theDots[i]='-';
	theDots[width]=0;
	output(theDots);

	int tmpNum=num1;
	int theLength;
	for (theLength=0;tmpNum;theLength++)
	{
		int tempNum=tmpNum;
		tmpNum/=10;
		theNumbers[theLength]=tempNum-(tmpNum*10);//this is some sort of rounding function
	}

	theSpaces[0]=0;
	for (int i=0;i<theLength;i++)
	{
		sprintf(thisLine, "%i%s", num1*theNumbers[i], theSpaces);
		for (int i=0;i<width;i++) theDots[i]='.';
		theDots[width]=0;
		strcpy(theDots+width-strlen(thisLine), thisLine);
		output(theDots);
		strcat(theSpaces, " ");
	}

	for (int i=0;i<width;i++) theDots[i]='-';
	theDots[width]=0;
	output(theDots);

	sprintf(thisLine, "%i", num1*num2);
	for (int i=0;i<width;i++) theDots[i]='.';
	theDots[width]=0;
	strcpy(theDots+width-strlen(thisLine), thisLine);
	output(theDots);
}

int main()
//you propably want to edit this
{
	multiply_frmt(1234, 1234, 11);
	output("");
	multiply_frmt(4321, 4321, 10);
	return 0;
}

This compiles without warnings and gives identical output in MSVC and mingw. You should be able to adapt it to your needs; if not, tell me.

commented: Another free lunch post -- and too complicated at that! -2

By keeping track of your spacing with a variable.

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.