LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-13-2020, 09:39 AM   #1
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 104

Rep: Reputation: 0
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.
 
Old 02-13-2020, 10:35 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,318

Rep: Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019
Quote:
Originally Posted by rahulvishwakarma View Post
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.
 
Old 02-13-2020, 11:05 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware FreeBSD Win10 MX
Posts: 9,596

Rep: Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071Reputation: 2071
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.

Last edited by BW-userx; 02-13-2020 at 11:09 AM.
 
2 members found this post helpful.
Old 02-13-2020, 03:55 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 19,514

Rep: Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016Reputation: 3016
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."
 
Old 02-13-2020, 05:52 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,318

Rep: Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019Reputation: 6019
Quote:
Originally Posted by jefro View Post
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.
 
Old 02-13-2020, 06:19 PM   #6
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,199

Rep: Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820Reputation: 3820
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
 
1 members found this post helpful.
Old 02-14-2020, 12:20 AM   #7
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 104

Original Poster
Rep: Reputation: 0
thanks a lot this solved my problem. post by BW-userx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] maximum filename lenth and maximum file size snjksh Linux - Newbie 5 07-22-2013 01:34 AM
Calculating new coordinates based on current position, bearing and speed Cotun Programming 14 04-06-2011 10:43 PM
distance between two points with x, y and z coordinates elsuccia Programming 3 05-17-2010 08:31 PM
Fluxbox questions, anti-aliasing, coordinates, the toolbar and volume Josh000 Linux - Desktop 5 04-04-2010 08:57 PM
Anyone know how to capture mouse click x and y coordinates? aatwell Programming 1 12-01-2007 04:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration