Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formfeed (\f) and vertical tab (\v) not working in C

After a long time I am writing a C program. While writing the program I had to use formfeed and vertical tab. so I used \f and \v in program.

But while running the code instead of Formfeed and vertical tab I can see symbols of male and female. I don't know why it is not working.

Below is my code sample :

#include<stdio.h>
#include<conio.h>

void main()
{
    printf("I am \f SpiderCode\n");
    printf("I am \v SpiderCode\n");
    getch();
}

[Note: I am using visual studio 2013 for above code]

Output of the above code

enter image description here

like image 457
SpiderCode Avatar asked Jan 17 '14 11:01

SpiderCode


Video Answer


1 Answers

This has nothing to do with your code, this is an issue with the display driver for the output of the program. The console does not recognise the '\f' and '\v' codes, so it just displays the corresponding characters instead. The '\f' maps to a character with a value 12 and '\v' to 11.

In the old days, you'd have something like ANSI.SYS running which would identify special codes and update the console, such as changing the colour, moving the cursor, etc.

like image 200
Skizz Avatar answered Sep 28 '22 01:09

Skizz