LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 08:39 AM   #1
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 138

Rep: Reputation: 2
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, 09:35 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
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, 10:05 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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 10:09 AM.
 
2 members found this post helpful.
Old 02-13-2020, 02:55 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
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, 04:52 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
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, 05:19 PM   #6
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084Reputation: 4084
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-13-2020, 11:20 PM   #7
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 138

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


Reply



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 12:34 AM
Calculating new coordinates based on current position, bearing and speed Cotun Programming 14 04-06-2011 09:43 PM
distance between two points with x, y and z coordinates elsuccia Programming 3 05-17-2010 07:31 PM
Fluxbox questions, anti-aliasing, coordinates, the toolbar and volume Josh000 Linux - Desktop 5 04-04-2010 07:57 PM
Anyone know how to capture mouse click x and y coordinates? aatwell Programming 1 12-01-2007 03:28 PM

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

All times are GMT -5. The time now is 11:19 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
Open Source Consulting | Domain Registration