Mail Archives: djgpp/1998/10/05/17:05:14
From: | Charles Krug <charles AT mail DOT pentek DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Undefined reference to npos (std::string find functions)???
|
Date: | Mon, 05 Oct 1998 16:54:02 -0400
|
Organization: | Pentek Corporation
|
Lines: | 38
|
Message-ID: | <361931EA.7C96A0D0@mail.pentek.com>
|
NNTP-Posting-Host: | mail.pentek.com
|
Mime-Version: | 1.0
|
X-Mailer: | Mozilla 4.04 [en] (WinNT; I)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello List!
I'm having difficulty using the C++ std::string functions.
A search of README, problems.txt et al did not mention this
#include <stdlib.h> //This is a workaround for header errors <<
from the FAQ
#include <string> // This includes std/bastring.h where both
find() and npos are defined
// This is from a subfunction actually, but it does the same
thing in main()
int main()
{
string fred = "abcdefg"'
int subIndex;
subIndex = fred.find('-'); // since '-' does not occur in
fred, npos should be returned
if (subIndex == npos) //<< This is flagged "npos
undeclared"
std::cout << "String not found\n"
return(0);
}
I have a workaround, but I rather dislike workarounds.
Any ideas are appreciated.
Charles
- Raw text -