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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:35:33+00:00 2026-06-03T15:35:33+00:00

This is probably going to be embarrassing, but here we go! I have the

  • 0

This is probably going to be embarrassing, but here we go!
I have the following code (shown below), and it is suppose to take an int and convert it to an char string. (I know about itoa() and snprintf, but I wan’t to make it work like this.) Everything seem’s to work fine until I try to print it and it displays nothing for the inttochar string. It’s probably just something stupid I’ve overlooked… I get the following result:

CHAR1: 4334321
CHAR2: 1234334
CHAR3: 

The code is here:

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

int main(){
int tester = 1234334;   //Test value
char temp[10];          //Temporary string array.       
char inttochar[10];         
int t = 0;

//Reads int to array.
while(tester != 0){
    temp[t] = (tester % 10) + '0';
    tester /= 10;
    t++;    
}
temp[t] = '\0';
t = 0;
printf("CHAR1: %s\nCHAR2: ",temp);


//Reverses the string.
for(int j=strlen(temp); j>=0;j--){
    inttochar[t] = temp[j];
    printf("%c",inttochar[t]);
    t++;
}
inttochar[t] = '\0';
t = 0;
printf("\nCHAR3: %s\n",inttochar);
} 
  • 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-03T15:35:35+00:00Added an answer on June 3, 2026 at 3:35 pm

    You should start from j=strlen(temp)-1, otherwise you assign \0 (which is what’s in temp[strlen(temp)]) to inttochar[0].

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

Sidebar

Related Questions

This is probably going to be very obvious, but here goes. I have two
I'm probably going to get abuse for this question but here goes. Oh but
This is probably going to be something simple I'm missing, but I have the
I'm probably going about this the wrong way, but here goes: I am starting
This is probably going to be an easy thing but I am having a
You can probably see where I am going with this - but is there
This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
This probably sounds like a terrible idea at first glance, but here is my
This is probably going to be more of a discussion or hypothetical question, but

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.