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

  • Home
  • SEARCH
  • 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 1050491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:46:40+00:00 2026-05-16T16:46:40+00:00

I ran the following: #include <stdio.h> typedef unsigned short boolean; #define false 0 #define

  • 0

I ran the following:

#include <stdio.h>
typedef unsigned short boolean;

#define false 0
#define true (!false)
int main()
{
    int STATUS = 0;
    int i = 0;
    boolean ret = true;
    for(i = 0; i < 99999; i++)
    {
        ret = ret && printf("Hello, World.");
    }
    if(!ret)
    {
        STATUS = -1;
    }

    return STATUS;
}

It completes in just under a second. Typically 0.9 – 0.92.

Then I changed int i = 0; to int *i = 0; and now I am getting execution times under 0.2 seconds. Why the speed change?

  • 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-05-16T16:46:41+00:00Added an answer on May 16, 2026 at 4:46 pm

    Your runtime is dominated by the time required to print to the console. i++ on an int* will increment the pointer by the size of a pointer. That will be either 4 or 8 depending on your computer and compiler settings. Based on the numbers you report, presumably it would be 4. So printf is executed only a quarter as many times.

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

Sidebar

Related Questions

just for testing i had created the following code: #include<stdio.h> int main(){ char *p
I have a question regarding the execution of the following program. #include<stdio.h> int main(void)
I ran the following code, but nothing came up on the console.... #include <stdio.h>
Recently I ran the following code on ideone.com (gcc-4.3.4) #include <stddef.h> #include <stdio.h> #include
I wrote the following program using VS2008: #include <fstream> int main() { std::wofstream fout(myfile);
In my class design I ran into the following problem: class MyData { int
I was trying to understand forks, and tried following in C: #include<stdio.h> #include <unistd.h>
The following code causes a segmentation fault. The executable is named './struct' #include <stdio.h>
I ran the following command: LOAD DATA INFILE '/Users/Tyler/Desktop/players_20120318.txt' INTO TABLE players FIELDS TERMINATED
I'm currently preparing a major Program-Update and ran into following problem: I've got a

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.