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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:05:18+00:00 2026-06-15T02:05:18+00:00

Here is the function I have, Sprite is an object in the program, and

  • 0

Here is the function I have, “Sprite” is an object in the program, and “GetSpriteAtPosition” just returns a pointer to the correct sprite at the coordinates.

My problem is that I store a letter in each sprite, in the form of an integer. 0 is a, and 25 is z, with everything in between respectively. I need my function to return a char* that gives me the letters of a row of sprites, so if in the program the sprites spell out “abcdefgh”, then that’s what I need this function to print out. There’s an 8×8 grid of sprites, and I’m getting the coordinates correctly, but I get an error that I can’t convert an int to a char* in the marked line. What can I do to get this to work?

Thanks in advance!

char* RowLetters(int row)
{
    char* pointer;
    for( int i = 0; i < 8; i++)
    {
        Sprite* selectedSprite = SpriteAtPosition(row*50, i * 50);
        if(selectedSprite != NULL)
        {
            char* temp = (char)(selectedSprite->Frame() + 97); //error here
            pointer = strcat(pointer, temp);
        }
        else
        {
            pointer = strcat(pointer, "test");
        }
    }
    return pointer;
}
  • 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-15T02:05:19+00:00Added an answer on June 15, 2026 at 2:05 am

    Try this:

            char temp = (char)(selectedSprite->Frame() + 97);
            pointer = strcat(pointer, &temp);
    

    I’ve changed the variable into a standard char rather than a pointer and then passed a reference to strcat() with the & operator.

    EDIT:

    As pointed out in the comments, this doesn’t work because &temp isn’t NULL terminated. I used to get around this when I programmed more C by doing the following.

            char temp[2];
            temp[0] = (char)(selectedSprite->Frame() + 97);
            temp[1] = '\0';
            pointer = strcat(pointer, temp);
    

    Of course, the temp array could be declared outside the for() loop for a little better performance (in theory).

    None of this addresses the other problems with the code like pointer never being declared. I think a broader understanding of the calling function would be in order to determine whether pointer should be allocated within this function or passed in by the caller.

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

Sidebar

Related Questions

I have the middleware that allows me to check user auth, here is: function
I have a function that uses the Google Blobstore API, and here's a degenerate
Just a little confused here... I have a function in postgres, and when I'm
I have a php function that fetches and returns tweets data from twitter as
Here is the code I have: private function drawRect():Sprite{ var rect:Sprite = new Sprite();
I have two functions here function Preloader() {} Preloader.prototype = { init:function() { //
I have a simple Jquery function here: function submit_selection(del,submit) { del='yes'; submit=true; var ITAMZ=new
Here is a jQuery slide function I have applied to a div on hover
I have the function prototype here: extern C void __stdcall__declspec(dllexport) ReturnPulse(double*,double*,double*,double*,double*); I need to
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });

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.