I'm having C++ problems on college work?

I have a college assignment where i have to create a program in a lesson but when trying at home i am find errors constantly.

," the program does not need to be anything substantial but must include the following using the appropriate PREDEFINED FUNCTIONS in C++.
The Time A String IOStream to output data to the terminal "

// Time attempt c++
#include <iostream>
#include <string>
using namespace std;
int main() {

int name;

cout << " please Enter your name";

cin >> name ;

cout << "Hi name" ;



System ( "pause");
return 0;
}



and for time
#include <ctime>
#include <iostream>
using namespace std;

int main() {
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
cout << (now->tm_year + 1900) << '-'
<< (now->tm_mon + 1) << '-'
<< now->tm_mday
<< endl;
}
i need to slot time into the above somehow.
I'm aware this all could be very wrong but I've only been learning week or 2

Im wanting to get the program to output hi NAME the time is. thanks for any help or links to help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
using namespace std;
int main() {

int name;  // change int to string

cout << " please Enter your name";

cin >> name ;

cout << "Hi name" ; // this will just output "Hi name" regardless of what the user inputted for their name
// change this to cout << "Hi " << name; 



System ( "pause");
return 0;
}


Your time program looks good, it correctly outputs today's date with formating.
Topic archived. No new replies allowed.