Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:59:32+00:00 2026-06-17T17:59:32+00:00

I have developed a C++ app to print Hello at 23:01:50 Here is my

  • 0

I have developed a C++ app to print Hello at 23:01:50

Here is my code

#include<iostream>
#include<string>
#include <time.h>
#include <windows.h>
using namespace std;
int main ()
{
    time_t start = time (&start);
    cout<<ctime(&start);
    while(1)
    {
        time (&start);
        if( ctime(&start) == "Fri Jan 18 23:01:50 2013\n" )
            cout << "Hello";
        Sleep(500);
        cout << ctime(&start);

    }
}

But output is:

Fri Jan 18 23:01:49 2013
Fri Jan 18 23:01:49 2013
Fri Jan 18 23:01:50 2013
Fri Jan 18 23:01:50 2013
Fri Jan 18 23:01:51 2013
Fri Jan 18 23:01:51 2013

Why Hello is not printed?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:59:33+00:00Added an answer on June 17, 2026 at 5:59 pm

    In C++ the equals operator “==” does not work as you expect for char pointers (which is what you are using). It is comparing the pointers which are actually pointing to different places in memory. To compare the strings (which is not the best way to do this check BTW) you will need to use a string comparison function.

    For example:

    if (strcmp(ctime(&start), "Fri Jan 18 23:01:50 2013\n") == 0)
    {
    }
    

    For more info see: http://www.cplusplus.com/reference/cstring/strcmp/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed my app using core data. It works fine in the simulator.
I have developed a blackberry app, in which I am using Persistent Storage to
I have developed a web app using a webservice. Everything works fine in the
I need your advice\help here. I developed a universal App and plan to have
I have an old web app developed in ASP.Net with the old type code
I have a app developed in PyQt4. It has icons set for windows and
i have developed an app which executes sql jobs. When I click on execute
I have developed an app that in testing has worked fine but when it
I have developed my app in android 2.2, and put it on google market
I have developed my app for tablet. Now I need to convert it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.