C programming in linux

Hi friends

In my linux application, i want to update output in same place i.e..

I want to display my output in specific location in screen(console output)

ITERATION 1:
(e.g. start diplay from 5th ROW 5th COLOUMN)
if my message is "hi" then

first time

'h' should print in 5th ROW 5th COL and 'i' should print in 5th ROW and 6th COL.

ITERATION 2:
(e.g. start diplay from 5th ROW 5th COLOUMN)

second time

'h' should print in 5th ROW 5th COL and 'i' should print in 5th ROW and 6th COL.
.
.
ITERATION n:
(e.g. start diplay from 5th ROW 5th COLOUMN)

nth time

'h' should print in 5th ROW 5th COL and 'i' should print in 5th ROW and 6th COL.

Can you please give me simple program?...

I think, this program tell you that what i am expecting?

#include<stdio.h>
int main ()
{
while(1)
{
printf("hi");
}
return 0;
}

output:

r0c0c1c2c3c4c5c6c7c8c9c10.... row->r
hihihihihihihihihihihihihihi.......infinite loop col->c

But, i need to display this "hi" in same place in screen(console output)

output must be:
r5c1c2c3c4c5c6
................h i (when i press ctrl+c to terminate infinite loop)

In short, i want to overwrite "hi".

Thanks & Regards
Venkat Gopu

Your program so far needs stdio.h, which you'd include at the top of your file like

#include <stdio.h>

As for whether your program does what you think it does, I have no idea what you think it does. Right now it just fills the terminal with "Display this statement in 5 row 5 column in disk every time". What do you mean by 'row 5 column 5 in disk'? What do you mean 'every time'?

#include<stdio.h>
int main ()
{
  while(1)
  {
          printf("\rhi");
  }
  return 0;
}

The \r character will send the cursor back to the beginning of the line without moving it down. (It doesn't clear the line, either.) If you're being given instructions to go a specific line though, this isn't sufficient, since printf can't go anywhere but across or down. You need to somehow tell the terminal what to do. You do this with ANSI escape sequences, which means printing the ESC character followed by a little bit of data. Here's two simple ones.

#include <stdio.h>

void cls(void)                  // clear screen
{       printf("\033[2J");                                      }

void gotoxy(int x, int y)       // go to coordinates
{       printf("\033[%d;%dH", y, x);                            }

int main(void)
{
        cls();
        gotoxy(50,5);
        printf("hi\n");
}

This isn't guaranteed to work in all terminals in all circumstances. (I can't think of a modern UNIX terminal it won't work in, but Windows certainly won't like it.)