[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 structure is called card_t and it has a number variable and suit variable which is an enum type.
if anyone could please tell me what i can do to let the struct pass into the print function accurately i would greatly appreciate it.
NVM i actually figured it out myself. just had to remove struct from prototype and function def. thanks anyway
Passing a array to a function, a basic feature in modern language, seems to be only possible in KSH. Not in BASH. Depite all my efforts I couldn't come to a solution. See the following examples:
It works perfectly in KSH:
#!/usr/bin/ksh
function print_array {
# assign array by indirect... (3 Replies)
Hi ,
I have three funcions f1, f2 and f3 .
f1 calls f2 and f2 calls f3 .
I have a global variable "period" which i want to pass to f3 .
Can i pass the variable directly in the definition of f3 ?
Pls help .
sars (4 Replies)
Hi All,
I have some questions regarding array arguements passing for Perl Function.
If @array contains 2 items , arguements passing would be like Code_A.
But what if @array needs to add in more items, the rest of the code like $_ will have to be modified as well (highlighted in red), which is... (5 Replies)
Hi,
I'm trying to write a function that reassigns an array to
another local array but the method used in reassigning
the array reformats the contents of the array which is
what I am trying to prevent.
The method used to load a file into an array works as
expected and the entire array is... (4 Replies)
EDIT: Nevermind, called a friend who is good at this stuff and he figured it out :D
Hi all,
So I'm trying to teach myself to write programs for unix in c. I am currently creating a program, and I need to pass a struct through a pipe, but I can't figure out how.
The struct I want to pass... (0 Replies)
Hi.
I have a problem with passing two dimensional array to a function.
First, let me show my code to explain what i am going to do:
I have function:void initialize_board(char board);which is supposed to modify content of passed array. I have read here: Question 6.18 how such arrays should be... (3 Replies)
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)
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,... (1 Reply)
Hi All
I have multiple arrays like below.
set -A val1 1 2 4 5
set -A val2 a b c d
.
.
.
Now i would like to pass the individual arrays one by one to a function and display/ do some action.
Note : I am using ksh
Can you please advise any solution...
Thanks in advance. (7 Replies)
Hello All,
I would like to ask help from you on how to pass variable value from a function that has been called inside the function. I have created below and
put the variables in " ". Is there another way I can do this? Thank you in advance.
readtasklist() {
while read -r mod ver... (1 Reply)
Discussion started by: aderamos12
1 Replies
LEARN ABOUT DEBIAN
xsol
XSOL(6) Games Manual XSOL(6)NAME
xsol - X Solitaire
SYNOPSIS
xsol
DESCRIPTION
This manual page briefly documents xsol , a simple Motif/ Lesstif version of the classic solitaire game. It was written for the Debian
GNU/Linux distribution because the original program does not have a manual page.
HOW TO PLAY
Solitaire is a card game. At the start you are presented with seven columns of cards. First has only one card, second one has two, third
three and so on (28 in total), but only the first card in every column is shown ('opened'). Also there is the deck (24 cards at the start),
and four emtpy places for suit stacks.
Cards in the deck and in the columns are unsorted, and the object of Solitaire is to use all the cards in the deck to build up the four
suit stacks in ascending order, beginning with the aces. You can accomplish that by dragging and dropping the red onto the black (and black
onto the red) cards between the columns, and between the deck and the columns (but not the other way around). When you see a whole turned
card, click on it to see it ('open' it) and to be able to move it somewhere. Deck is opened by clicking on it; once you reach the end of
the deck, just click once more and you'll reopen it.
If you reach a point when you can't move any more cards to the stacks, and rearranging cards in columns and the deck gets you nowhere, the
game is over. Start it again.
OPTIONS
You can access all options within the program, through the 'Game' menu. There you have four options:
New game - start a new game,
Undo - undo last move,
Options - configure these options:
Timed game - should we count the seconds?
Keep score - should we count the score?
Show number of cards in deck - should we show it?
Draw one - card from the deck,
Draw three - cards from the deck.
About - shows information about the author.
Exit - quits the game.
AUTHOR
xsol was written by Brian Masney <masneyb@newwave.net>, and this manual page was written by Josip Rodin <jrodin@jagor.srce.hr>.
Debian Project March 1999 XSOL(6)