Quote:
Originally Posted by dreamboy
Good Morning to every body! I am a hobby programmer and join in this forum today. I have code a program of stop watch in c++ and compiled and run well.but I want to see the Win32 application istead of console appln. Please anybody can help how to code for win32? The source code of console appln for stop watch as given below.
code
// example2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{int ms=0,s=0,m=0;
char stop;
cout << endl << "Hello ! This is a Stopwatch application programmed by T.Kannan" << endl;
cout << endl << " Press Q to Quit else any Charactor followed by enter Key to start STOP WATCH" << endl;
cin >> stop;
while(stop != 'Q')
{
do
{
for(ms=1; ms<=100; ms++)
{
cout << " Minutes : Seconds : Milliseconds";
s=s+(ms/100);
m=m+(s/60);
cout << endl << endl << " " << m << " : " << s << " : " << ms << endl;
if(s==60)s=0;
printf("\nBY");
printf("\n");
printf("\nT.KANNAN");
system ("CLS");
}
}while(m<1);
ms=0;
s=0;
cout << endl;
cout << endl << "Hello ! 1 Minute duration gone programmed by T.Kannan" << endl << endl;
cout << "M: " << m;
cout << " S: " << s;
cout << " MS: " << ms << endl << endl;
m=0;
cout << " Press Q to Quit else any Charactor followed by enter Key " << endl;
cin >> stop;
}
return 0;
}
/code
|
Other then your name what you actually wrote in this code?
Your code remindes me 286, 386 era when I started learning C language.
It's printf() for screen output and system() for calling DOS commands or any executable eg .exe,. com, .bat etc.
Anyway code is not good.
Run and check how many minutes it takes to show 1 minutes on different PCs with processors of different speed.
It is not stop watch. It runs for so called 1 minute under all cercumtences.
There was no need of clearing screen in inner loop that also using system("CLS"). Use gotoxy() instead and over wright new time over old time..
Anyway from where ever you start keep trying.
It is good to search and read code on net.
Not only try them also try to modify them. This way you will learn.