Sponsored Content
Full Discussion: Xlib help - Array of Structs
Homework and Emergencies Homework & Coursework Questions Xlib help - Array of Structs Post 302744409 by Spiritvs on Friday 14th of December 2012 09:50:36 AM
Old 12-14-2012
Xlib help - Array of Structs

Hey guys!
First of all english is not my main language so sorry for any english mistakes.
Im from Portugal!

1. The problem statement, all variables and given/known data:

Im having a problema creating and array of structs for a work i need to do. (xLib)

2. Relevant commands, code, scripts, algorithms:

So i created a struct, that holds 4 ints:

X = X position
Y = Y postion
dimX = horizontal dimension
dimY = vertical dimension

this 4 ints represent a rectangle.

The struct:

Code:
typedef struct _blocks {
    int X, Y ,dimX, dimY;
} str_blocks;

So now i want to assign values to this int's, but since i dont want just one rectangle i want, for example 3, the best thing to do is to create an array of this struct right?

So for 3 rectangle:

Code:
str_blocks blocks[3];

blocks[0] = {50, 50, 150, 20};
blocks[1] = {200, 50, 150, 20};
blocks[2] = {300, 150, 150, 20};

So this doesnt work and i dont know why. ive been looking in the internet and
saw lots of examples where they declare the values like this, im obviously missing something...

Tried to assign value by value:

Code:
blocks[0].X = 50;
blocks[0].Y = 50;
blocks[0].dimX = 150;
blocks[0].dimy = 20;

blocks[1].X = 200;
blocks[1].Y = 50;
blocks[1].dimX = 150;
blocks[1].dimy = 20;

blocks[2].X = 300;
blocks[2].Y = 150;
blocks[2].dimX = 150;
blocks[2].dimy = 20;

3. The attempts at a solution (include all code and scripts):

I tried to use:

Code:
str_blocks blocks[3];

blocks[0] = {50, 50, 150, 20};
blocks[1] = {200, 50, 150, 20};
blocks[2] = {300, 150, 150, 20};

To give diferent values to the blocks.


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Im from Portugal anyway.

ESTG IPVC Portugal - Viana do Castelo
Engenharia da Computação Gráfica e multimédia.
Teacher name: João Raposo
www . estg . ipvc . pt

Last edited by Corona688; 12-14-2012 at 11:44 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

pipes + structs

heya got a small problem here. im trying to pipe eg: 'ls | more'. i have created a command line parser which separates ls and more into two commands. i have also created a struct, each struct has a command name, number of arguments, redirect_in, redirect_out, pipe_in, etc etc.... eg: struct... (0 Replies)
Discussion started by: mile1982
0 Replies

2. UNIX for Advanced & Expert Users

xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (3 Replies)
Discussion started by: karpoand
3 Replies

3. UNIX and Linux Applications

vncserver xlib error

Hello! Im running tight VNC on Red Hat Enterprise Linux 4.0. How can I increase the number of X clients that I can run in a VNC session?I need to run aproximately 500 programs in one VNC session, but at this time I can only 236 -> i've tryed to launch 250 xclock's in background and when it... (0 Replies)
Discussion started by: karpoand
0 Replies

4. Programming

problems with drawing in x using xlib

Hi all, I'm currently learning xlib and I've encountered a bizarre mistake: function calls such as XDrawPoint, XDrawLine, etc., don't seem to work; a blank window with nothing in is appears. I believe this has something to do with the window manager I use, fluxbox. After checking the code and... (0 Replies)
Discussion started by: hydronium
0 Replies

5. Programming

Xlib simple program.

I don't know if it is right to ask you this. Can someone help me write a simple Xlib program,with button on it,and all that button do is switch 2 messages. I have tried and tried,but never get past Hello World. Can someone help me please? ---------- Post updated at 10:17 PM ---------- Previous... (2 Replies)
Discussion started by: megane16v
2 Replies

6. UNIX for Dummies Questions & Answers

Xlib Errors

Hi, I am handling user issues in my team. Users have their Unix session running on Citrix MFU. Recently, I was suppose to address a user issue which is as below: Gets the below error when tries to open nedit: Xlib: connection to ":165.0" refused by server Xlib: Client is not... (1 Reply)
Discussion started by: mspatil0037
1 Replies

7. Programming

[solved]help passing array of structs to function in c

this is my code to try and prinnt out a deck of cards. the print function worked when used inside main without being a function but now i cant get it to work as a function probably since i dont know how to pass a struct array in c. I gave it a shot but i keep getting an assortment of errors. The... (0 Replies)
Discussion started by: bjhum33
0 Replies

8. UNIX for Advanced & Expert Users

xlib and keyboard events

1. If there's some better place where xlib experts hang out, please tell me. Despite an assiduous search, I could not find an xlib reflector. 2. My actual question: In an xterm, I want to grab and process all keyboard events in a program running inside the xterm. For example, with my program... (5 Replies)
Discussion started by: N7DR
5 Replies

9. Programming

Xlib help - Array of Structs

Hey guys! First of all english is not my main language so sorry for any english mistakes. Second im a total beginner in programming, still i have a school work to do and i found a problem. Probably something easy to solve but it's driving me crazy. So i created a struct, that holds 4 ints: ... (1 Reply)
Discussion started by: Spiritvs
1 Replies

10. Programming

Xlib registering

hey, Im new to the linux world. Lately, I have tried to create a glx window with xlib, making it a popup window(fullscreen) so I set override_redirect to true. Im happy with the removed borders, but apparantly, the application doesnt show up in the left bar in ubuntu, neither when I press alt... (4 Replies)
Discussion started by: thedardanius
4 Replies
ICHECK(8)						      System Manager's Manual							 ICHECK(8)

NAME
icheck - file system storage consistency check SYNOPSIS
icheck [ -s ] [ -b numbers ] [ filesystem ] DESCRIPTION
Icheck examines a file system, builds a bit map of used blocks, and compares this bit map against the free list maintained on the file sys- tem. If the file system is not specified, a set of default file systems is checked. The normal output of icheck includes a report of The total number of files and the numbers of regular, directory, block special and character special files, quota nodes, and sym- bolic links. The total number of blocks in use and the numbers of single-, double-, and triple-indirect blocks and directory blocks. The number of free blocks. The number of blocks missing; i.e. not in any file nor in the free list. The -s option causes icheck to ignore the actual free list and reconstruct a new one by rewriting the super-block of the file system. The file system should be dismounted while this is done; if this is not possible (for example if the root file system has to be salvaged) care should be taken that the system is quiescent and that it is rebooted immediately afterwards so that the old, bad in-core copy of the super- block will not continue to be used. Notice also that the words in the super-block which indicate the size of the free list and of the i- list are believed. If the super-block has been curdled these words will have to be patched. The -s option causes the normal output reports to be suppressed. Following the -b option is a list of block numbers; whenever any of the named blocks turns up in a file, a diagnostic is produced. Icheck is faster if the raw version of the special file is used, since it reads the i-list many blocks at a time. SEE ALSO
filsys(5), clri(8), dcheck(8), fsck(8), ncheck(8) DIAGNOSTICS
For duplicate blocks and bad blocks (which lie outside the file system) icheck announces the difficulty, the i-number, and the kind of block involved. If a read error is encountered, the block number of the bad block is printed and icheck considers it to contain 0. `Bad freeblock' means that a block number outside the available space was encountered in the free list. `n dups in free' means that n blocks were found in the free list which duplicate blocks either in some file or in the earlier part of the free list. BUGS
Since icheck is inherently two-pass in nature, extraneous diagnostics may be produced if applied to active file systems. Since default file systems vary with installations, icheck should use fstab(5). It believes even preposterous super-blocks and consequently can get core images. 3rd Berkeley Distribution ICHECK(8)
All times are GMT -4. The time now is 10:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy