Solved

URGENt: Search and Store

Posted on 2003-10-22
6
188 Views
Last Modified: 2010-04-02
Hi
I have been able to read a text file . This text files contains information from separate channels ( Channel 1, Channel 2, and so on upto 20 channels ). Each row belongs to a separate channel and each row is made up of columns of data.
The data in "row one" it represents a specific "Channel"
It could be information from "Channel one" or could be information from "Channel two" or any other channel.
Now i have to store and present information as
Channel 1
Channel 2
Channel 3
..............
..............
and so on .

The only way i can get to know which is channel one is by " reading through a line and find " three alphabets corresponding to that channel e.g. " if row one contains X, Y, Z it is channel 1, if it is X,Z, Y it is channel 2  and so on.
I have only three alphabets to relate and find channel .

How do i write the search string for that ?
since i have been able to read and successfully store the data. Please guide me in the right direction.
Please bear in mind i am begineer and only a a few months in C++ and MFC . So please explain things  for a novice.

Thanks.
iCe
0
Comment
Question by:iceb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9602314
Is there a specific way in which these 3 characters are laid out? Can you give a demonstration of this?
0
 
LVL 1

Author Comment

by:iceb
ID: 9602420
Sorry my fault.
It is of the format shown below
S.No.      Channel Name        alphabet1      alphabet 2    alphabet 3
1   ,         blah                ,           x          ,          y       ,             z
2   ,         trash               ,           y          ,          x       ,             z
3   ,         grin                 ,           x          ,                  ,             y                    
4
5
6
...............
................

The file is separated by commas. There might be cases that the alphabet is missing as shown in second line.

Thanks for reply.
I hope that makes it a little more clearer.

.iCe.
0
 
LVL 3

Expert Comment

by:gkatz
ID: 9602463
does this have to be done in C++, other languages are made for this such as Perl or any other language with regular expressions.

-gkatz
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
n_fortynine earned 500 total points
ID: 9602479
You can use a map to do this. Each element in a map is a pair of data.
for example:
#include <map>
map<string, string> ChannelMap;
You can use the first item to hold the string denoting the channel and the second the channel name. Adding an entry to a map is like this (for example):
string x = map("xyz");
map("xyz") = "blah";
//if there is a missing letter you can use a space I guess"x y"?
to search a map, you can write a simple loop as follow:
  //say
  string searchString = "blah";
  for(map::const_interator CI = ChannelMap.begin(); CI != ChannelMap.end(); CI++)
  {
     if(CI->first == searchString) cout <<CI->second << endl;
  }

Will this structure help?
0
 
LVL 1

Author Comment

by:iceb
ID: 9602754
!@#$%^&*() Confusion and more confusion.
Thats the state of my mind !
thanks for replying neways.
Yes plz it has to be done in C++ .
As i am developing an application with GUI  . so i believe i can't use "cout. "
But i will try and let you know if it works.
i used "CArray" to store the data .  

Thanks.

.iCe.

0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9602937
>>As i am developing an application with GUI  . so i believe i can't use "cout. "
>>But i will try and let you know if it works.

That's just an example of how to search for values in a map :)
What I would do is to read the data from the file and put them in the map, then whenever I am given a channel's "code" I'll just search the map for the channel name. It's just convenient so that I don't have to write my own "array" structures.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 164
C++ standard library based binary archive format 6 112
How to split this in C++ 4 130
Beginner to Unreal Engine 4 5 120
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question