Click here to Skip to main content
15,900,108 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get the handle of a Popup Menu for a window? Pin
Hans Ruck24-Jan-06 22:30
Hans Ruck24-Jan-06 22:30 
QuestionMRU in a popup submenu Pin
manosza24-Jan-06 9:17
manosza24-Jan-06 9:17 
QuestionPassword protect a document Pin
arnoldkempt24-Jan-06 8:41
arnoldkempt24-Jan-06 8:41 
AnswerRe: Password protect a document Pin
Maximilien24-Jan-06 8:47
Maximilien24-Jan-06 8:47 
GeneralRe: Password protect a document Pin
arnoldkempt25-Jan-06 7:27
arnoldkempt25-Jan-06 7:27 
AnswerRe: Password protect a document Pin
sps-itsec4624-Jan-06 12:56
sps-itsec4624-Jan-06 12:56 
QuestionMS Access ODBC Compact and Repair Pin
Anfernius24-Jan-06 6:20
Anfernius24-Jan-06 6:20 
QuestionWTF: std::string.find_first_of woes Pin
Sebastian Schneider24-Jan-06 5:25
Sebastian Schneider24-Jan-06 5:25 
Hi guys,

I hope I do not have overlooked something small in my code, or you probably will make fun of me:

I have a function that determines if a critical error has occured in really old code which just returns a list of structs containing error information. Someone already added a std::string containing the error-message to these structs, and I can simply get that one.

I need to ignore a certain error message (which virtually always occurs), so I wrote the following code:

<br />
std::string noRecords = "no records found"; // Dont ask me why, but this message always is wrong.<br />
for (int i = curr.numberOfElements(); i > 0; --i) <br />
   {<br />
      if (std::string::npos != curr.currentElement.info.find_first_of(noRecords))<br />
      {<br />
          return true;<br />
      }<br />
      curr.setToPreviousElement();<br />
   }<br />
return false;<br />
<br />

which is supposed to return true ("a real error occured") if there is any other error than "no records found" and false otherwise (i.e. "just noRecords errors").

As mentioned before, I cannot change the implementation of the errorList. Just ignore the naming, please, as I had to "obfuscate" a little.

Well, the result: obviously "no records found" is a part of "unexpected end of file". Thats what currElement.info (the std::string) contains.

I also tried the following comparisons:
curr.currentElement.info.find_first_of(noRecords) < 0

curr.currentElement.info.find_first_of("no records found") < 0

curr.currentElement.info.find_first_of("no records found") != std::string::npos

but to no avail. I tried over 100 info strings with the above function, it never got inside the conditional.

I HOPE that this is really simple (that means, I messed up somewhere). find_first_of actually IS the string::find_first_of(), I double-checked that.

GNAH.




Cheers,
Sebastian

--
Contra vim mortem non est medicamen in hortem.

-- modified at 11:25 Tuesday 24th January, 2006
AnswerRe: WTF: std::string.find_first_of woes Pin
Christian Graus24-Jan-06 14:20
protectorChristian Graus24-Jan-06 14:20 
GeneralRe: WTF: std::string.find_first_of woes Pin
Sebastian Schneider25-Jan-06 2:07
Sebastian Schneider25-Jan-06 2:07 
Question__gc* equivalent in VC++ 2005 Pin
madhusri24-Jan-06 4:32
madhusri24-Jan-06 4:32 
AnswerRe: __gc* equivalent in VC++ 2005 Pin
toxcct24-Jan-06 4:34
toxcct24-Jan-06 4:34 
GeneralRe: __gc* equivalent in VC++ 2005 Pin
madhusri24-Jan-06 4:44
madhusri24-Jan-06 4:44 
GeneralRe: __gc* equivalent in VC++ 2005 Pin
Christian Graus24-Jan-06 14:34
protectorChristian Graus24-Jan-06 14:34 
GeneralRe: __gc* equivalent in VC++ 2005 Pin
Ryan Binns24-Jan-06 17:59
Ryan Binns24-Jan-06 17:59 
QuestionHello Pin
nne-vitamin24-Jan-06 4:06
nne-vitamin24-Jan-06 4:06 
AnswerRe: Hello Pin
toxcct24-Jan-06 4:32
toxcct24-Jan-06 4:32 
GeneralRe: Hello Pin
nne-vitamin24-Jan-06 4:42
nne-vitamin24-Jan-06 4:42 
GeneralRe: Hello Pin
toxcct24-Jan-06 4:45
toxcct24-Jan-06 4:45 
GeneralRe: Hello Pin
nne-vitamin24-Jan-06 5:00
nne-vitamin24-Jan-06 5:00 
GeneralRe: Hello Pin
toxcct24-Jan-06 5:03
toxcct24-Jan-06 5:03 
GeneralRe: Hello Pin
nne-vitamin24-Jan-06 5:12
nne-vitamin24-Jan-06 5:12 
GeneralRe: Hello Pin
toxcct24-Jan-06 5:15
toxcct24-Jan-06 5:15 
GeneralRe: Hello Pin
nne-vitamin24-Jan-06 5:23
nne-vitamin24-Jan-06 5:23 
GeneralRe: Hello Pin
nne-vitamin24-Jan-06 5:38
nne-vitamin24-Jan-06 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.