Solved

URGENt: Search and Store

Posted on 2003-10-22
6
180 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
  • 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now