473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

about: map

I made a map like this:

typedef struct
{
char * Source;
bool DirFlag;
} RegInfo_t;

struct Comp
{
bool operator()( RegInfo_t k1, RegInfo_t k2) const
{
return strcmp( k1.Source, k2.Source )<0;
}
};

map< RegInfo_t, time_t, Comp > m_RegInfo;

RegInfo_t mystruct;
mystruct.Source = "Test";
mystruct.DirFlag = false;
time_t t;
time(&t);

m_RegInfo.insert( make_pair( mystruct, t) );

My Question:

m_RegInfo[mystruct] == t ????

Please help , thanks.

Jul 19 '05 #1
5 1642
How can you read a file, character by character, including whitespace?

Revman
Jul 19 '05 #2
"Revman" <Re****@cox.net> wrote in message
news:gI1lb.1902$CP6.1378@okepread04...
How can you read a file, character by character, including whitespace?


cin.get()

-Mike
Jul 19 '05 #3
Stanley Yue wrote:
My Question:

m_RegInfo[mystruct] == t ????


That's not a question. It's a code fragment followed by 4 question
marks.

Jul 19 '05 #4
Mike,

Thanks for the response. I'm sorry, I wasn't very clear.

I needed to read a text file character by character, including whitespace.

Its a homework assignment to read names (one to a line) and put them in
strings.

first, middle, last.

I found my answer with on at cplusplus.com

inChar = inFile.get();

I seem to have written my class to eat between 2 and 10 characters after
each /n.

My big decision statements are

if (inChar == ',' || inChar == '/n'|| inChar == EOF) // last-first-middle
entry method

if (inChar == ' ' && flag == 0) // first-middle-last entry method

// flag is incremented when first is assigned to prevent inadvertently
entering the decision cycle again.

and

if ( strlen(first.c_str()) > 1 &&
strlen(middle.c_str()) > 1 &&
strlen(last.c_str()) > 1) // verifying that each name has an assignment
before exiting.
I believe my mistake lies in this logic somewhere but I'm too close to my
problem to see it.

Thanks in advance for any help!

Revman


Jul 19 '05 #5
Revman wrote:
if ( strlen(first.c_str()) > 1 &&
strlen(middle.c_str()) > 1 &&
strlen(last.c_str()) > 1) // verifying that each name has an assignment
before exiting.


Only for standarize: Why don't you use:

if (first.length()>1 &&
middle.length()>1 &&
last.length()>1)

don't you know the std::string has a length() member? :)

Jul 19 '05 #6

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

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.