C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Reading data from text file and highlighting users selection? Posted by CookieMonster on 28 Jan 2013 at 2:10 PM
I would be very greatful if someone could point me in the right direction. So far I have a program which reads in a series of currencies from a text file. When the user presses a key 1 to 9 a different currency is selected i.e. 1=British pound, 2=Euro. Depending upon the two numbers the rate is then calculated. I was wondering whether it is at all possible to highlight the users selection i.e. whenever they press 1 change the colour of the text British Pound, 2 Euro and so on. I presume it would go in either one of these functions but im not entirely sure. Any help though would be much appreciated.
void convert(void)
{
	
	gotoxy(20,17);
	printf("Select currency to convert from ");

	from=(getch()-48);
	while(from<1 || from>9)
		from=(getch()-48);
	
        gotoxy(20,17);
	printf("                                ");

	gotoxy(20,17);
	printf("Select currency to convert to ");

	to=(getch()-48);
	while(to<1 || to>9)
		to=(getch()-48);

	gotoxy(20,17);
	printf("                              ");
	gotoxy(20,17);
	printf("Enter amount: ");
	amount=gfloat();

	gotoxy(20,19);
	printf("%1.2f",(amount/rates[from-1])*rates[to-1]);
	//getch();
	//system("cls");             
	pause();
}

void read_file(float *rates)
{
	char buff[80];
	int i;
	
	i=0;
	while(fgets(buff,80,fpin)!=NULL)
	{  //      x   y
		gotoxy(17,7+i);
		printf("%d %s",i+1,buff);
		gotoxy(42,7+i);
		printf("%d %s",i+1,buff);
		if(fgets(buff,80,fpin)!=NULL)
		rates[i++]=(float)atof(buff);
	}
	fclose(fpin);
}


Thread Tree



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.