Can someone please help me with this code, it should change numbersd to text. It compiles but the CMD box has the incorrect output.

#include "stdafx.h"
#include <stdio.h>
#include <string>
//#include <math.h>    // for exp(), pow() and log10()

int _tmain(int argc, _TCHAR* argv[])
{
	int number=5;
	char text[10][10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
	int repeat;
	char *output;

	//Get the number
	//int temp1 = scanf("%d", &number);

	//How many iterations
	//float temp2 = log10(float(number));
	repeat = 1;

	//Generate output
	for (int i=1; i<repeat; i++) {
		int temp3 = number % 10;
		output = text[temp3];// . " " . output;
		number /= 10;
	}

	//Print output
	printf ("%s\n", output);

	return 0;
}

Learn about the wonder that is code tags.
http://www.daniweb.com/forums/announcement8-3.html

What are you trying to do here:

output = text[temp3];// . " " . output;

First, if you want to copy the contents of text[temp3], you're going to have to use [search]strcpy[/search]. Secondly, why are you filling 'output' with stuff each iteration and then wiping it out on the next iteration?

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.