473,549 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading a text file and storing the content in arrays in C++

1 New Member
Any help will be appreciated.

problem:

I have a text file which contains the following information

address name

202 blue ridge Mark Smith
156 Racoon Henry jones
............... ............... ...
etc.... etc..

there is no line breaks in the file

i need to read the file and store the address in array of addresses. also read the name and store it in array of names.

how do you you do that in C++
Sep 1 '06 #1
1 3247
f1engineer
5 New Member
It is necessary to have logical separator from the address and name. Example:

If each record is at the new line of the file, then You can read latest one, two or three words that are the name. All the previous words are the address:

London Berry streed 23 Michael Shumacher
London Berry streed 25 Andrew Smith Lawson

Another way is to separate the address and name in the file (if Your program generate this files) with double space, and when read data, reaching the place of of double space will be sign that the name is reached.

Best regards
Sep 1 '06 #2

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

Similar topics

7
7077
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field?...
1
2662
by: Hayat | last post by:
Hello, I have a column (text datatype) and has to send an email as a text (not attachment) using cdonts. I am reading the data from text column storing in a varchar field and saying cdonts.body = . This way I can send email to as a text format. Now, my problem is when length of data is greater than the 8000 chars it truncates the rest of...
2
311
by: slickn_sly | last post by:
I'm trying to read a text file and storing each line to a specific array. so if i define an array - name, address,... and in my text file I have something like: John Doe Seattle, Washington Julie Walsh New York, New York
9
3589
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so that its buffer is bigger than this. I did this expecting the data to be read in one pass.
7
11768
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) Your first task is to write a program which reads this file into two parallel arrays in memory. One array contains the titles, and the other array...
4
2196
by: nzjohnc | last post by:
Hi all, just started c ,need some help for storing values in arrays.I have opened the file for reading using fscanf,cos its got only three fields,but when i try to get the values to array,I'm getting the address values.If any one could give some advice on the procedure or concept of getting the values from a text file and storing them in arrays...
21
3018
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z 00000000_00 0 000 000 000 0000 000 I need to read the file line by line and eventually parse out each piece of the file and store in arrays that...
3
3160
by: jasvinder singh | last post by:
Respected Sir/madam, Can you help in providing code in 'C' for Reading text file with n number of rows and columns and putting the result in arrays.The sample file is as follows: rim_label = 'aeff5' state 0 = 'eee' state 1 = 'ffffff' . .and so on...
3
1232
by: electromania | last post by:
I'm trying to read from a text file. The format of the text file is 1999 78686 2000 78999 2001 80003 .................... .................... ................... 2002 45489 (so forth).
0
7520
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...
0
7957
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...
0
7809
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...
0
6043
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...
0
3500
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...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
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
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
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...

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.