How to pass structs to functions
From: Panda2 (Panda_Mobile_2_at_hotmail.com)
Date: 02/27/05
- Previous message: nick: "Re: do not understand the questions(the link of the questions)"
- Next in thread: Alf P. Steinbach: "Re: How to pass structs to functions"
- Reply: Alf P. Steinbach: "Re: How to pass structs to functions"
- Reply: Anthony Borla: "Re: How to pass structs to functions"
- Maybe reply: Panda2: "Re: How to pass structs to functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Feb 2005 18:10:32 -0800
I hope someone can help me with this, maybe an example.. I've spent so
long trying to work it out I'm about to lose it..
Say I have a struct like:
struct S1{
int x[10];
char y[10];
}data[10][10];
and i want to pass it to another function by reference (i want to
change the values in the original function (like I said Noob!))..
I just can't work out how to do it...
I was thinking slong the lines of:
#include <cstdlib>
#include <iostream>
using namespace std;
void SomeFunction( don't know what to put here )
{
for(int a=0; a<9; a++)
{
or how to refer to it
}
return;
}
int main(int argc, char *argv[])
{
struct S1{
int x[10];
char y[10];
}data[10][10];
S1* sptr;
SomeFunction(sptr);
for(int x=0; x<9; x++)
{
cout << data[x][x].int[x] << "\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
Maybe someone can help fill in the blanks, or offer a correct solution
in case I'm wildly off the path.. (more than likely)
- Previous message: nick: "Re: do not understand the questions(the link of the questions)"
- Next in thread: Alf P. Steinbach: "Re: How to pass structs to functions"
- Reply: Alf P. Steinbach: "Re: How to pass structs to functions"
- Reply: Anthony Borla: "Re: How to pass structs to functions"
- Maybe reply: Panda2: "Re: How to pass structs to functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]