473,791 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populate array from text file - help

Hi,

I have to do the following, and would like you suggestions
on how I could achieve it the best way:

I have a text file in the following format:

12345 54321 98765 56789
(3 spaces between numbers)

Those are reference numbers for monetary values. They are
associated with values in this format

1.00 2.00 ... 9.00 10.00 20.00 ... 90.00 100.00 200.00 ...
900.00 1000.00 2000.00 ... 9000.00...

Which is the best way for me to do it? Because I have to
do the following: given the monetary value 123.00:

3.00 x 1 = 3.00
2.00 x 10 = 20.00
1.00 x 100 = 100.00

And supposing:

array[3] = 12345
array[20] = 23456
array[100] = 34567

I would sum those values to obtain a key to validate my
text file in my server.

Everything is implemented, expect for the part in which
the array is populated (i'm working with a "fake" array).

Any help will be very appreciated. And no, this is not
homework. I'm a newbie with C++ and I'm implementing a
component to process messages of payment. That's why I'm
asking help :)

TIA

Marcelo
Nov 16 '05 #1
1 2056
Hello,

You would use the fopen()/fgets()/fclose() to read from file.
You would then use strstr() or strtok()/strtol() to convert strings to
integers as you're parsing the data you read.

--
Elias
http://lgwm.org/

"Marcelo" <sm***@h0tmail. 08ujkllk98yu2js 83.com> wrote in message
news:0b******** *************** *****@phx.gbl.. .
Hi,

I have to do the following, and would like you suggestions
on how I could achieve it the best way:

I have a text file in the following format:

12345 54321 98765 56789
(3 spaces between numbers)

Those are reference numbers for monetary values. They are
associated with values in this format

1.00 2.00 ... 9.00 10.00 20.00 ... 90.00 100.00 200.00 ...
900.00 1000.00 2000.00 ... 9000.00...

Which is the best way for me to do it? Because I have to
do the following: given the monetary value 123.00:

3.00 x 1 = 3.00
2.00 x 10 = 20.00
1.00 x 100 = 100.00

And supposing:

array[3] = 12345
array[20] = 23456
array[100] = 34567

I would sum those values to obtain a key to validate my
text file in my server.

Everything is implemented, expect for the part in which
the array is populated (i'm working with a "fake" array).

Any help will be very appreciated. And no, this is not
homework. I'm a newbie with C++ and I'm implementing a
component to process messages of payment. That's why I'm
asking help :)

TIA

Marcelo

Nov 16 '05 #2

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

Similar topics

11
8151
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
10
2737
by: Craig Keightley | last post by:
I have the following array: function showCPUs(){ //name brandID dualCore dualProcessor var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=; var cpuItem=;
1
1406
by: dibblm | last post by:
I have a text file being created and need the values from the array that gets created to populate my text file. I am new and not very good. Kinda borrowing bits and pieces from here and there, so if my code is a mess (Which it is ) don't be alarmed. Myfile is the array that gets populated and I need it's results returned to the text file . Below is the code... Dim oFile As System.IO.File
1
6532
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page. I am able to call values from file in my jsp page. But as dynamic values can be any in no...
0
4075
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to java class which creates a xml file based on values entered in dynamic jsp page. Now i want to read all those values entered to xml in my other jsp page.But as dynamic values can be any in no i don't know how could i populate all those in my jsp...
4
5669
by: | last post by:
Hi all, I want to create a method that does the following: 1) Programmatically instantiate a new XmlDataSource control 2) For each file in a named directory, make a "FileSystemItem" element 3) On each FileSystemItem Element, make two child nodes, one with the file name, one with the file size. ie. <filesystemitems> <filesystemitem>
3
9143
by: OliveOyl3471 | last post by:
In Visual Basic.NET 2003, how do you populate a two dimensional array from a text file? I know how to check file existence, open the file for read, etc. I just can't get it to read more than one record from the file into the array. I have declared a 2 dimensional, 12 row, 2 column array named strVenues(11,1) in the public section of the form. The instructor is gone for the week, so I can't ask her any more questions about this project...
1
2031
by: Tarik Monem | last post by:
Hi everyone and I hope that you can help. I am trying to send a value of a cell within a Datagrid to my php file which has a simple sql query: here's the php: <? $server = "localhost";
7
7339
by: jcnone | last post by:
Does anyone know how to populate form fields on a html web page (client side) with data from an Excel file (CSV) or text file. I am currently having to input data to many text fields manually. I would like to transfer the data into the web form programatically from a CSV/text file. How can this be done? I am new to javascript, but I will work through the challange if possible. Please help! Thanks. Jman
0
9517
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
9997
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
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
5435
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
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
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.