-2

我刚开始编程,我不知道我在做什么。我的教授给了我们要做的程序集,我已经完成了,但是当我编译文件时,我得到了

" J:\Untitled1.cpp 在函数 `int main()' 中:

“36 J:\Untitled1.cpp '<<' 标记之前的预期主表达式”

这是全套,现在记住我是初学者:

/** 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; 
}
4

3 回答 3

0

删除第 36 行的分号

<<ctime (&nowIsTheMoment); << endl;
                         ^
                         |
于 2013-09-04T05:53:28.980 回答
0

您忘记了 to #include <string>and 资格stringand coutwith std::

于 2013-09-04T05:53:37.370 回答
0

从删除.之后开始,<time.h>它可能会有所帮助。然后你得到了这个

ctime (&nowIsTheMoment); <<endl;

无法编译,因为<<需要一个左操作数(即:删除分号)。

我并不是要粗鲁,但在 StackOverflow 上提问之前,您应该更加努力一点……

于 2013-09-04T06:00:22.717 回答