structure, function and array

Hi,

I am trying to get this particular program to work. I can get my structure with an array to work, but not with the function. I can get the function and structure to work, but not with the array. Could someone direct me to an area to see an example of function, using structure in an array, such as struct tsudpod[3], but in a function? here is my code below...thanks for any help.

in tsupod.h is only function declarations.

#include <string>
#include <iostream>
#include "tsuPod.h"
#include <cstdlib>
using namespace std;
const int LENGTH = 25;
struct TsuPod
{
string Title;
string Artist;
int Size;
// maybe don't need this bool TrackUsed;
}song;
//Function declaration inside tsudpod.h

void initTsuPod (TsuPod);


int main()
{

const int NUM_SONGS = 8; //we will have the maximum 8 slots with some slots being empty
const int MEMORY_SIZE = 25; //total memory size of tsuPod in MB

int Result;
int temp = 0;
cout << "HELLO from within main\n";


initTsuPod(song); //call function initTsuPod


system("PAUSE>NUL");
return 0;

}
void initTsuPod(TsuPod r)
{
r.Title = "The Stranger";
r.Size = 0;
r.Artist = "Billy Joel";
cout << r.Title << endl;
cout << r.Size << endl;
cout << r.Artist << endl;

}
Last edited on
I think you should use code tags to make your code easier to read.
You call the initTsuPod() with the arguement song.Where does it get this?
The function doesn't seem to do anything except print what Title, Size and Artist have been initialized to.
What is in tsupod.h?
What output do you get? and where is this at odds with your expectations?
buffbill, he did initialize the TsuPod variable "song" on line 13.
Topic archived. No new replies allowed.