// secondstohhmms.cpp : Defines the entry point for the application.
//

#include <iostream>
using namespace std; 
#include "StdAfx.h"


void main()
{
int time,hour,min,sec;
cout<<"Enter time in seconds :";
cin>>time;
hour=time/3600;
time=time%3600;
min=time/60;
time=time%60;
sec=time;
cout<<"\n\nThe time is : "<<hour<<"::"<<min<<"::"<<sec;
}

Errors:

>c:\users\desi9991\documents\visual studio 2010\projects\secondstohhmms\secondstohhmms\secondstohhmms.cpp(4): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>c:\users\desi9991\documents\visual studio 2010\projects\secondstohhmms\secondstohhmms\secondstohhmms.cpp(12): error C2065: 'cout' : undeclared identifier
1>c:\users\desi9991\documents\visual studio 2010\projects\secondstohhmms\secondstohhmms\secondstohhmms.cpp(13): error C2065: 'cin' : undeclared identifier
1>c:\users\desi9991\documents\visual studio 2010\projects\secondstohhmms\secondstohhmms\secondstohhmms.cpp(19): error C2065: 'cout' : undeclared identifier

Get rid of this line:

#include "StdAfx.h"

It's not really necessary, unless you absolutely must use precompiled headers. I'm guessing you don't need them.

I see your point, but Then I get this error:

c:\users\desi9991\documents\visual studio 2010\projects\secondstohhmms\secondstohhmms\secondstohhmms.cpp(26): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

Ah, Visual Studio Fatal Error C1010.

From the linked article:

If you do not use precompiled headers in your project, set the Create/Use Precompiled Header property of source files to Not Using Precompiled Headers. To set this compiler option, follow these steps:

  • In the Solution Explorer pane of the project, right-click the project name, and then click Properties.
  • In the left pane, click the C/C++ folder.
  • Click the Precompiled Headers node.
  • In the right pane, click Create/Use Precompiled Header, and then click Not Using Precompiled Headers.

It's not really necessary, unless you absolutely must use precompiled headers. I'm guessing you don't need them.

If building a native app, it's not "necessary"
For DotNet and MFC apps, it is necessary (unless you want to do a few work-arounds).

This article has been dead for over six months. Start a new discussion instead.