LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to get maximum x and y coordinates in c++ in centos 7.5 (https://www.linuxquestions.org/questions/linux-software-2/how-to-get-maximum-x-and-y-coordinates-in-c-in-centos-7-5-a-4175669527/)

rahulvishwakarma 02-13-2020 08:39 AM

how to get maximum x and y coordinates in c++ in centos 7.5
 
hi to all, i've centos 7.5 in VM. I am trying to build a simple c++ program in which i have to know max x and y coordinate of terminal in runtime. how to do that.

TB0ne 02-13-2020 09:35 AM

Quote:

Originally Posted by rahulvishwakarma (Post 6089515)
hi to all, i've centos 7.5 in VM. I am trying to build a simple c++ program in which i have to know max x and y coordinate of terminal in runtime. how to do that.

You write your code to do it, that's how. Since you don't share your code, or show us ANY effort on your part, that's all we can tell you; we can also suggest you look at your OTHER thread about graphic programming in C++, which seems VERY similar to this. And **AGAIN**, you need to do basic research first...this has been asked and answered on this very site in the past, and there are MILLIONS of hits in Google for "find terminal size in C++", which you could find if you tried to look

A good number of your threads follow this pattern; you show no effort of your own, no research, and seem to ask us to look things up for you, and don't even bother to follow up in most of them.

BW-userx 02-13-2020 10:05 AM

yet one more hit on google
Code:

#include <stdio.h>
#include <X11/Xlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
int main()
{
        Display* d = XOpenDisplay(NULL);
        Screen* s = DefaultScreenOfDisplay(d);
        int W = WidthOfScreen(s);
        int H = HeightOfScreen(s);
        XCloseDisplay(d);
        struct winsize w;
        ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
        printf("Display Size\nWidth:X = %d Height:Y = %d\nTerminal Size\n"
        "lines %d\ncolumns %d\n" ,W,H,w.ws_row,w.ws_col);
    return 0;
}
//complie with -lX11

Converting that to C++ is easily done.

jefro 02-13-2020 02:55 PM

Phrases like this do not belong in technical threads, "Per site rules." Post relevant information to questions please.



"A good number of your threads follow this pattern; you show no effort of your own, no research, and seem to ask us to look things up for you, and don't even bother to follow up in most of them."

TB0ne 02-13-2020 04:52 PM

Quote:

Originally Posted by jefro (Post 6089700)
Phrases like this do not belong in technical threads, "Per site rules." Post relevant information to questions please.



"A good number of your threads follow this pattern; you show no effort of your own, no research, and seem to ask us to look things up for you, and don't even bother to follow up in most of them."

You may then want to tell Jeremy to take those things out of the site FAQ then.

jeremy 02-13-2020 05:19 PM

jefro,

I've made clear that members who continually post without meting some basic requirement to help them can be pointed to https://www.linuxquestions.org/quest...#faq_welcomelq, which offers some guidance.

TB0ne, I've also made my request for you to let others answer in these cases pretty clear.

--jeremy

rahulvishwakarma 02-13-2020 11:20 PM

thanks a lot this solved my problem. post by BW-userx


All times are GMT -5. The time now is 04:58 AM.