Created
October 31, 2022 07:19
-
-
Save pwnwriter/7ceb3a8cf47946c4647b6781b1ccde75 to your computer and use it in GitHub Desktop.
// print text in center !
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/ioctl.h> | |
#include <unistd.h> | |
int main(void) | |
{ | |
char name[] = "pwnwriter"; | |
struct winsize pwnwriter; //using a structure defined in unistd.h library..... | |
ioctl(STDIN_FILENO, TIOCGWINSZ, &pwnwriter); /*calling te ioctl function... it save the window detail | |
pwnwriter structure*/ | |
int widthToPrintName = pwnwriter.ws_col / 2; /*dirvinding the total width by 2 to write | |
text in center*/ | |
for (int i = 1; i <= widthToPrintName; ++i) | |
printf(" "); //printing the half screen with space.. | |
printf("%s\12", name); //printing the name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment