Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 29th, 2007, 04:13 PM
Registered User
 
Join Date: Dec 2007
Location: salzburg, , Austria.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default pointer to struct

Please help me!
I have the problem of rare using of c language.

in deklaration part i have defined a struct:
define NBR = 10;
typedef struct {char *name; int nr} Testtype;

in main programm i will point to Testtype (and this should be an array of NBR, but this is my problem). i did:
Testtype t_type = {"sdfsdf", 10};
Testtype *test_type = t_type;

So far so good, but who i could predefine my other (up to NBR) structs?,
thanks for helping, go.


go
Reply With Quote
  #2 (permalink)  
Old January 10th, 2008, 07:23 AM
Registered User
 
Join Date: Jan 2008
Location: , , Ukraine.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to ScorpZ
Default

Hello.

Testtype *test_type = t_type;

It's mistake.!
 You must initialize pointer by -
1) other pointer
2) NULL
3) object's address

for example

Testtype *test_type = &t_type;

Reply With Quote


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me - fill dataGridView from struct array ranjithemail C++ Programming 0 May 10th, 2008 11:53 PM
Dynamic array of struct bobwrx C# 2 September 14th, 2006 06:12 AM
class and struct variables are confusing webworldman C# 2 August 7th, 2006 03:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.