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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:02:51+00:00 2026-05-26T18:02:51+00:00

I’m trying to write a program which would write on the console at a

  • 0

I’m trying to write a program which would write on the console at a very specific position in the screen. Say for example from column 20 to column 39.
After each write, the line is “reset” thanks to the \r parameter. This ensures that the line remains static and only the specific fields are updated.

Problem is, i can instruct printf to write from column 0 to 19 without erasing the rest of the line, but it seems i’m not able to instruct printf to write from column 20 onwards without erasing in the process columns 0 to 19.

Is there a (standard) way to do this ?
using something else than printf is possible.

[Edit] I’ve read there is a gotoxy() function in C which is available for windows apparently, and can be emulated in Linux using ncurses. Is there any problem with this function ?

  • 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-26T18:02:52+00:00Added an answer on May 26, 2026 at 6:02 pm

    You can try printing as many backspaces (and spaces to clear old text) as needed to position the cursor.

    No guarantee it works for you … if it does: no guarantee it works on the other computer 🙂

    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    
    int main(void) {
      int i, k;
      time_t oldtime = time(0);
      if (oldtime == (time_t)-1) {
        fprintf(stderr, "time function does not work on this machine\n");
        exit(EXIT_FAILURE);
      }
      while (time(0) == oldtime) /* void */;
    
      printf("fixed stuff: ");
      for (i = 1; i < 6; i++) {
        int val = pow(10, i) * i;
        printf("%d", val);
        fflush(stdout);
        oldtime = time(0);
        while (time(0) == oldtime) /* void */;
        if (i < 5) {
          for (k = 0; k < i + 1; k++) printf("\b \b"); // go back; erase; go back again
          fflush(stdout);
        } else {
          puts("");
        }
      }
    
      return 0;
    }
    

    It works for me, on both Linux and Windows computers

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am currently running into a problem where an element is coming back from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put

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.