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 4534750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:19:12+00:00 2026-05-21T14:19:12+00:00

why cant i get this int64 working? i compile with g++ -x c++ -o

  • 0

why cant i get this int64 working?
i compile with g++ -x c++ -o program source.c
it keeps starting over with -2147483648 above 2147483647 ….

#include <stdint.h>
#include <inttypes.h>
#ifdef __cplusplus
#include <cstdio>
#include <cstdlib>
#include <cstring>
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif

int main(int argc, char* argv[])
{
    int64_t i;
    for(i = 0; i < argc; ++i)
        printf("argv[%d]: %s\n", i, argv[i]);

    char string [512];
    int64_t a1 = atoi((const char*) gets(string));
    int64_t limit = a1 + 99999999999

    while(a1 <= limit)
    {
        char command[10000];
        sprintf(command, "%d", a1);
        FILE* pFile = fopen ("myfile.txt","wa");
        fprintf (pFile, "%s\n", command);
        fclose (pFile);

       a1= a1 + 4321;
    }
    return EXIT_SUCCESS;
}

c

  • 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-21T14:19:12+00:00Added an answer on May 21, 2026 at 2:19 pm

    I think you should replace

    sprintf(command, "%d", a1);
    

    with

    sprintf(command, "%lld", a1);
    

    Using the wrong format specifier is undefined behaviour. AFAIK, using %d as the format specifier in gcc forces only 32 bits to be printed out – thus resulting in what looks like overflows in your output file.

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

Sidebar

Related Questions

Hey .... im working on a Iphone app ..i cant get this working: i
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I can't seem to get a custom action working. I might be doing this
I tried different ways to do this but i cant get it work. this
I cant get this to work anymore Here is my code: ImageView jpgView =
I cant get this to work. The State field is empty on certain occassions,
I am having a nightmare trying to get this working (and have looked at
This shouldn't be so hard but I just can't seem to get this to
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I think this must be simple but I can't get it right... I have

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.