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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:13:54+00:00 2026-05-15T17:13:54+00:00

I was trying to make a program but, when add sprintf to the equation,

  • 0

I was trying to make a program but, when add sprintf to the equation, I get the following error:

Program received signal: “SIGABRT”

My sprintf is written as follows:

int i;
int g;
char b[6];
sprintf(b, "%d", i*g);

If you need to see the whole code here it is (but you probably don’t, just in case though):

#include <stdio.h>
#include <stdlib.h>


int main (int argc, const char * argv[]) {
    int i;
    int g;
    char b[6];
    char temp[6];
    char c[6];
    int lol;
    int revlol;
    int assign;
    for (i = 100; i < 1000; i++)
    {
        sprintf(b, "%d", i*g);
        for (g = 100; g < 1000; g++)
        {
            for (lol = 5; lol > -1; lol--)
            {
                for (revlol = 0; revlol < 6; revlol++)
                {
                    temp[lol] = b[revlol];
                }
                if (temp == b)
                {
                    for (assign = 0; assign < 6; assign++)
                    {
                        c[assign] = b[assign];
                    }
                }
            }
        }
    }
    printf("%s", c);
}

But, the problem only happens when I use sprintf. Also note: I am not using itoa because my compiler does not allow it.

Any help would be appreciated!

  • 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-15T17:13:55+00:00Added an answer on May 15, 2026 at 5:13 pm

    In the actual code you assume that buffer b is big enough to print the result for i*g into, but you never initialize g before its first use on this line:

    sprintf(b, "%d", i*g);
    

    But even if g was initialized, you are missing that the buffer also has to hold the \0 character, thus it is too small.

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

Sidebar

Related Questions

I'm trying to make a program packer but i always fail because when i
I'm trying to make a program that lets you input any one-step equation, and
im trying to use this method to make my characters but i get the
im trying to use this method to make my characters but i get the
I am trying to make a program which does a very basic calculation, but
Im trying to make a program that retrieves an endless amount of numbers that
I'm trying to make a program that, using pointers, detects lines in an image
I'm trying to make a program which will create a sum of directories the
I'm trying to make a program that can be hosted by many peoples, like
I am trying to make a program that can take an .mp3 file from

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.