How to print structure with function?

[code]I'm trying to pass my structure to a function using switch method, so that It will ask for user's name and age then then from the switch method it will call a print function, but my coding is not working. could anyone enlighten me?
Last edited on
1) Please use code tags when posting code, to make it more readable.

2) In SwitchFunction, you're attempting to use the value of choice before it's ever been set, so it's going to be a random number.
@MikeyBoy 2: what do you mean can you show an example of how it would be?

My switch function work and all but its just that my print function does not print out the value from the structure that i previously entered by addRecord function.
Well then, what does it print? Does it print the wrong values? If so, what values does it print? Does it print garbage? Does it print nothing?

Why are you being so coy about giving us details? Don't you want us to be able to help you properly?

EDIT: And I'm right about you not initialising choice before you use it. If it's working, it's only working by accident.
Last edited on
its just that i've been stuck with this problem for a few days now. and don't know why. sorry if this irritates you. and yes it print out a bunch of garbage :|
Asking the question doesn't irritate people. Withholding information about the problem you're trying to solve irritates people. Why on earth would you withhold information that would help people solve your problem for you?

In printAllRecords(), you create a new, uninitialised FootballClub object, and immediately print out the contents. It's not surprising you're getting garbage, because you haven't set those values to anything.

Presumably, what you really intended that function for is to print out the contents of an object that gets passed in as a function parameter?
Last edited on
oh i see.. do i set parameter from the main or the addrecord function? there was no example in the book for that :[
I'm 99.9999% certain that your book will tell you how to pass parameters into functions. It's one of the most basic and fundamental elements of C and C++ programming, so if it doesn't show you how to do that, then throw it away and find a decent book instead.

You've deleted your code from your OP, so I can't advise you on where to make your function calls from.
Topic archived. No new replies allowed.