Is there an output function in C that keeps the cursor ON the last char printed and NOT after it? (Aside from using gotoxy(wherex()-1,y))

Thanks
Ami

Recommended Answers

All 6 Replies

No, there is no such function. If you want the cursor at the end, use an operating system specific function to move it there after the text is printed.

#include <stdio.h>
int main()
{
    printf("Cursor one space back!!!\b");
    
    getchar();
    return 0;
}

ssharish2005

#include <stdio.h>
int main()
{
    printf("Cursor one space back!!!\b");
 
    getchar();
    return 0;
}

ssharish2005

EXACTLY what I was looking for.

Thanks!

The backspace erases the character underneath the cursor just like it does when you type it on your keyboard. Is that what you want?

Well, sorry forgot to mention that. It does display the cursor one position back. But the actual internal char is erased. But the char would be displayed. As Ancient Dragon said.

It would be useful if you just wanted to display the out put message but not use that same out message for further manipulation because the string is altered.

ssharish2005

I always want to overwrite the last char so I think it's ok. It's been working fine on my little testing I'm doing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.