Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 10-30-2005, 01:40 AM   #1 (permalink)
kennez
Registered User
 
Join Date: Oct 2005
Posts: 1
kennez is on a distinguished road
Reading comma-seperated files into an array - Please Help!

I have a mini-assignment to do at University over the next two weeks or so, to be written in C, but the trouble is, I haven't written a line of C in nearly 2 years, so I am extremely rusty. Anyway, here is what I need help with:

I have data in a file in the following format (comma seperated)

Code:
Origin,Destination,Flight No.,Aircraft type,Days of week,Departure time,Arrival time,Begin Date,End Date
Essentially, what I have to do is read the data contained in this file into an array in order to run a search function on it.

What the program is required to do is to take in the Origin and Destination, and display all of the flights that go between these two places, along with the rest of the information given above.

The file is absolutely huge, but we were told that if we can get it to work on about 10 lines of data, there is no reason why it shouldn't work with a larger file.

I have absolutely no idea how to go about reading this data into an array. I have a C book which briefly covers opening files, but it doesn't mention comma-seperated data in files.

We were told that strtok() is the best way to go about doing this, and I have
found an example of using it here, but I haven't got a clue how to read comma-seperated text in. We are using standard C for this exercise, not C++.

Any help on this really would be appreciated, as I have absolutely no idea how to do this. Once I have the data in an array, I should be able to muddle through it, but getting started is the problem.

Thanks in advance for your help.

Cheers,
Malcolm
kennez is offline   Reply With Quote
Old 10-30-2005, 02:16 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
search this forum for strtok theres a few good examples there, one that comes to mind is this thread with a closer look at my read_entries() function, it should give you some idear.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple reverse programm silex Standard C, C++ 3 01-22-2005 08:03 AM
reading a folder of files Androto Standard C, C++ 29 12-21-2004 05:26 PM
reading files from a directory and printing philthee Java 4 10-29-2004 05:01 AM
Installing and using CMUgraphics library. Valmont Standard C, C++ 12 03-29-2003 08:39 AM


All times are GMT -8. The time now is 04:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting