Posts tagged c++

get machine local time using c++, windows only

hi all,
here are some c++ codes to show local time of the running machine.
download time.cpp
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
SYSTEMTIME time;
GetLocalTime (&time);//(c++)
cout<<time.wHour<<”:”<<time.wMinute<<endl;
cout<<”——————–”<<endl;
system(“time /T”); //(dos)
return 0;
}

get your computer name using c++, windows only

hi all,
you can get your computer name, which use windows operating system by using this code:
/*********/
#include <iostream>
#include <windows.h>
using namespace std;
int main(){
char name[100];
DWORD length=100;
GetComputerName(name, &length);
cout<<name<<endl;
return 0;
}
/*********/

colorful C++ in Dos

hi all,
most of computer science students are writing countless number of c++ programs. those programs usually runs on Dos. Day by day, this makes them hate the Black Screen more and more. Today we will see some tips to add color to those programs.
what are we going to see is tested on Microsoft Visual C++ [...]