-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, 8 Nov 2003 14:41:59 +0000 Gedi <gedi@ntlworld.com> wrote:
Hi Jerry,
I have just started on pointers and passing by address a few days ago.
The first problem you pointed out was a silly mistake on my part. I should have noticed that. I guess spotting silly mistakes like that will become second nature in time.
The second issue makes sense now. Thanks for taking the time to explain Hopefully it will work. However, if you want to use pointers: void student_info(struct students *data); void print(struct students *data);
replace: student[i] = student_info(student[i]); with: student_info(&student[i]); The in student_info, replace data. by data-> as below: cin.getline (data->name, 30); Do the same thing in print. Note that since you are using a pointer to the student structure in student_info(), you do not need to return anything. (But you might want to report success or failure). Additionally, you could pass the structure into the two functions by using the C++ pass by reference. That would require only changes to the function prototypes and definitions: struct students &student_info(struct students &data); Also note that in C++, a struct is the same thing as a class with all functions and data public. Your struct actually has a default constructor. In the case of your program, it really does not matter. But, student_info() could be moved into the struct and renamed as the constructor, but you probably have not studied classes yet. - -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/rQfB+wA+1cUGHqkRAsVmAJ9bOgO1YzhDnk2juojVhwtxoXiedQCePJib QOm9FYUGEa6Ibgw01pn75Rg= =0/UH -----END PGP SIGNATURE-----