我刚开始编程,我不知道自己在做什么。我的教授给了我们程序集,我已经完成了,但是当我编译文件时,我得到了
“J:\ Untitled1.cpp在函数`int main()'中:
“36 J:\ Untitled1.cpp期望在'<<'之前的primary-expression令牌“
这是全套,现在记住我是初学者:
/** CONCEPTS PROGRAM #1, TEMPLATE
PROGRAM Name: Yay.cpp
Program/assignment:
Description: Finds total
Input(s):
Output(s):
suffering_with_c++
Date of completion
*/
//included libraries
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <time.h.>
#define cls system("cls")
#define pauseOutput system("pause")//
using namespace std;
int main()
{
//variable declaration/initialization
time_t nowIsTheMoment;
time(&nowIsTheMoment);
string dateTime;//
cls;
cout <<"\new live in the moment--only this moment is ours. The Current Date and time is: "
<<ctime (&nowIsTheMoment); << endl;//
cout << "\nMy name is Moe Joe." <<endl;//
cout << endl << "I think Computer Programming with C++ will be a bit more PHUN now!"
<< endl;
dateTime = ctime(&nowIsTheMoment);//
cout << endl << "\nYo ho! I am here now...\n" << endl;
cout << endl << "The Current Date and time is: "
<<dateTime <<endl;//
cout << "\nI know clearly that, if I DO NOT comment my programs/project work thorougly, I will lose substantial points.\n" ;
cout << "\bHere is Pause Output in action....\n" << endl;//
pauseOutput; //
cls;//
return 0;
}
答案 0 :(得分:0)
删除第36行的分号
<<ctime (&nowIsTheMoment); << endl;
^
|
答案 1 :(得分:0)
您忘记了#include <string>
并使用string
限定cout
和std::
。
答案 2 :(得分:0)
首先删除.
后<time.h>
应该有所帮助。然后你得到了这个
ctime(&amp; nowIsTheMoment); &LT;&LT; ENDL;
无法编译,因为<<
需要左操作数(即:删除分号)。
我不是故意粗鲁,但在StackOverflow上提问之前你应该稍微努力一下......