473,598 Members | 3,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Poblem with Structural array

9 New Member
Hey, I am trying to declare an array of 12 structs that will hold information from a file input.

I have my struct

Expand|Select|Wrap|Line Numbers
  1.  
  2. struct month
  3. {
  4.     float totalRain, highTemp, lowTemp, averageTemp;
  5. };
  6.  

and this is my array

Expand|Select|Wrap|Line Numbers
  1. struct month fullYear[12];
  2.  
These are my struct variables.

Expand|Select|Wrap|Line Numbers
  1. month jan, feb, mar, april, may, june, jul, aug, sept, oct, nov, dec;
  2.  

each of the struct variables will be placed in the array respectively, but I am unsure how to read the information from the file putting them in their rightfull place.


The values in the input file will be separated by blanks. A sample single line in the input file might be:
20.1 78.2 40.1


How would I go about placing 20.1 into jan.totalRain in my array?



I hope I explained myself clearly, If not just let me know.

Thank you all for your help in advance.
Sep 3 '07 #1
1 1196
Ganon11
3,652 Recognized Expert Specialist
Access jan by using month[0], feb with month[1], ... dec with month[11]. For your operations, instead of typing jan.totalRain = /* your code here */;, type month[0].totalRain = /* your code here */;
Sep 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2772
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
575
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a print_r cmd any suggestions would be great. Thanks much Todd //avShed array Array ( => Array ( => 1 => 08:00 ) => Array ( => 1 => 08:05 ) => Array ( => 1 => 08:10 ) => Array ( => 1 => 08:15 ) => Array ( => 1 => 08:20 ) => Array...
3
4751
by: LC | last post by:
hi, i worry about people doing something they shouldn't to my db and I would like to track any structural changes (who and which)to my db. I am using oracle 8.0.6.0.0 and 9.2.0.2.0. regards, Lee Cho
10
2642
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to prefer composition over inheritance. Can anyone provide some reasons why this is the case (based on "real-world" experience)? For example, is structural inheritance more difficult to maintain? More difficult to test? Have a larger impact on...
2
2146
by: adam.spamfree | last post by:
Hi, I was just wondering if anyone could give me an explanation of what the difference between "structural" and "presentational" elements is. thanks a lot.
7
1791
by: Mike McGavin | last post by:
Hi everyone. I'm searching for a quick and dirty way to have psql record the SQL statements that I enter, especially those related to the database structure. My main motivation is to help keep what will probably be a production server up-to-date with my development server. I've thought a little about replication, but the current options for that seem like overkill for the relatively small database that I have. I'm particularly
1
2001
by: Hans | last post by:
In developer studio 2003, I created a solution containing a C# windows app. I want to re-engeneer the app using Visio Professional 2003. How can I make visio create the structural diagram??? Hans.
2
2134
by: Graville | last post by:
All, OK wasn't sure where to post this one but this should hopefully be ok. I am looking for a way to streamline some of the process within our dev team. One of the areas that often takes time and gets missed by the guys is the generation of SQL Scripts and checking them into sourcecontrol. I know that using SQL Server profiler you directly trace ALTER, DELETE and CREATE statements on all objects in your database. You can also
2
2429
mikek12004
by: mikek12004 | last post by:
Initialy i wanted to create a short description of a text to be shown as preview, I found the following which worked OK $length = 35; // The number of words you want $words = explode(' ', $b_keimeno); // Creates an array of words $true_length=count($words); //to see if description smaller than $length $words = array_slice($words, 0, $length); $s_keimeno = implode(' ', $words); if ($true_length>$length) $s_keimeno.="...";
0
7991
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
7902
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
8395
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
8398
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
5438
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3898
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
3939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1504
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1250
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.