473,765 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Structures problem

Hi MegaBrains,

Working in Dev-C++ I defined the following structure

#define NO_SECTIONS 6
struct Track{
int Number;
int noElems;
float x_pos;
float y_pos;
int type;
int state;
} ;
Track Trk[NO_SECTIONS];

I want to fill the Trk array with data from a data file like so:

int trk_no, divis, i;
float posx, posy;

i=0;
ifstream inifile ("init.txt") ;
if (inifile.is_ope n())
{
while (! inifile.eof() )
{
inifile >> trk_no,divis,po sx,posy ;

Trk.Number[i]=trk_no; <-----
Trk.noElems[i]=divis; <-----
Trk.x_pos[i]=posx; <-----
Trk.y_pos[i]=posy; <-----
i++;
}
inifile.close() ;
}

The following error typr is given for each of the lines marked above:

request for member `Number' in `Trk', which is of non-class type
`Track[6]'

So what did I do wrong?
Thanx!!
Mar 9 '06 #1
2 1588
Jehudi <je********@wan adoo.nl> writes:
Hi MegaBrains,
...
So what did I do wrong?
...
Trk.Number[i]=trk_no; <-----

Try Trk[i].Number=trk_no;
etc.
Mar 9 '06 #2

Thanks Tim,
That was the problem!

Tim Love wrote:
Jehudi <je********@wan adoo.nl> writes:

Hi MegaBrains,
...
So what did I do wrong?
...
Trk.Number[i]=trk_no; <-----


Try Trk[i].Number=trk_no;
etc.


Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1505
by: Ivan | last post by:
Hi All, I have a problem with marshaling complex structures (containing numbers, strings, arrays of another structures) to native C function in dll. I have already posted same question to .compactframework thread, but nobody helped. main problem is that I have tried all the workarounds I have found in the Inet but nothing worked... I tried passing IntPtr, Byte Arrays, Serialisation, even used OpenNETCF, but
4
3862
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system that doesn't offer dynamic memory allocation (to be clear: no malloc, no realloc), and with rather tight memory constraints. Writing my own malloc to do dynamic allocation from some static pool isn't really an option, for various reasons, not...
4
2866
by: Animesh | last post by:
Hi All, I don't know whethher this is possible or not. This is the result of a bad design problem. Here I go; I have a structure like this: typedef struct _s_index_entry { char *doc_id; double s_id;
7
6063
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should populate a series of structures of specified variable composition. I have the structures created OK, but actually reading the files is giving me an error. Can I ask a simple question to start with: I'm trying to read the file using the...
4
1356
by: zacks | last post by:
A common programming technique I use in VB is making a collection of structures. But if Option Strict is on (which I would prefer), the .Add that adds the structure to the collection is flagged with a compiler error (invalid type conversion). Is there a way to use a collection of structures WITH the Option Strict On?
11
3784
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
44
5805
by: svata | last post by:
Hello, I wonder how to resize such array of structures using realloc()? #include <stdio.h> #include <stdlib.h> #define FIRST 7 typedef struct { char *name;
29
6355
by: Mik0b0 | last post by:
Hallo to everyone. This fall I am going to start data structures as a part of C language course. The problem is I could not find any satisfying tutorial about structures in C. There are plenty of books about data structures in C+ + etc., could anyone please recommend me such a C -specific book ? And another question: are data structures (like stack, structure etc.) used in C++ identical to those in C and is it possible to use C++ books to...
4
1971
by: yugidnu | last post by:
Hi all, I have the following problem. I have to access different types of structures getting passed via a void pointer. I have the code snippet here. --------------------------------------------------------------------------------------------------------------------- /* N structures each having different type of member variable .*/
4
4728
by: cleanrabbit | last post by:
Hello! I hate having to do this, because im almost certain there is someone in the world that has come across this problem and i just havent found their solution yet, so i do appologise if this has already been covered. I have been trying to learn c# as fast as possible in the last month and in doing so i have been re-visiting old C/C++ problems and trying to overcome them in C#. What i have is a very complex serise of structures. Id...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.