OK, why doesn't this work:
string EraseCommas(str ing &numericStri ng)
{
UINT16_T commaPosition;
commaPosition = numericString.f ind(",");
while (commaPosition != string::npos);
{
numericString.e rase(commaPosit ion);
commaPosition = numericString.f ind(",", commaPosition);
}
return numericString;
}
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population;
compiles with
make -f import.mak TARGET=pc
g++ -c -DTARGET_PC -Wall -g -I /. -I /mingw/include/ -I /devstudio/vc/include -o ./pc/import.o -Wno-deprecated import.cpp
import.cpp: In member function `virtual bool COUNTY::parseOb ject(BOOK&)':
import.cpp:213: parse error before `>>' token
make: *** [pc/import.o] Error 1
Compilation exited abnormally with code 2 at Sun Oct 17 21:23:41
--
% Randy Yates % "And all that I can do
%% Fuquay-Varina, NC % is say I'm sorry,
%%% 919-577-9882 % that's the way it goes..."
%%%% <ya***@ieee.org > % Getting To The Point', *Balance of Power*, ELO http://home.earthlink.net/~yatescr 7 1350
Randy Yates schrieb: OK, why doesn't this work:
string EraseCommas(str ing &numericStri ng)
this way it can take a temporary, like description.sub str(...) below:
string EraseCommas(con st string &numericStri ng) {
see above, and replace all occurances of numericString with result below:
string result = numericString; UINT16_T commaPosition;
UINT16_T (some user-defined 16-bit unsigned type?) might very well not
be large enough for string::npos... :
string::size_ty pe commaPosition; commaPosition = numericString.f ind(","); while (commaPosition != string::npos);
^ oops, empty endless loop :-) { numericString.e rase(commaPosit ion);
erase one char, not everything from the comma till the end:
numericString.e rase(commaPosit ion, 1); commaPosition = numericString.f ind(",", commaPosition); }
return numericString; }
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population;
compiles with
make -f import.mak TARGET=pc g++ -c -DTARGET_PC -Wall -g -I /. -I /mingw/include/ -I /devstudio/vc/include -o ./pc/import.o -Wno-deprecated import.cpp import.cpp: In member function `virtual bool COUNTY::parseOb ject(BOOK&)': import.cpp:213: parse error before `>>' token
Yep :-(
This line:
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex -
begIndex + 1))) >> population;
is parsed as a function declaration followed by >> population
unfortunately. This one works:
istringstream is(EraseCommas( description.sub str(begIndex, endIndex -
begIndex + 1)));
is >> population;
Regards,
Malte
Malte Starostik <ma************ *@t-online.de> writes: Randy Yates schrieb:
OK, why doesn't this work: string EraseCommas(str ing &numericStri ng) this way it can take a temporary, like description.sub str(...) below: string EraseCommas(con st string &numericStri ng) { see above, and replace all occurances of numericString with result below: string result = numericString;
But, at the risk of being overly anal, that's not what I want to accomplish.
I'd like EraseCommas(num ericString) to operate either as a stand-along function
that operates on numericString,
string numericString;
EraseCommas(num ericString);
or as a string
string line;
string numericString;
line = EraseCommas(num ericString);
But thanks much for the help, Malte.
--Randy UINT16_T commaPosition; UINT16_T (some user-defined 16-bit unsigned type?) might very well not be large enough for string::npos... : string::size_ty pe commaPosition;
commaPosition = numericString.f ind(","); while (commaPosition != string::npos); ^ oops, empty endless loop :-) { numericString.e rase(commaPosit ion); erase one char, not everything from the comma till the end: numericString.e rase(commaPosit ion, 1); commaPosition = numericString.f ind(",", commaPosition); } return numericString; } istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population; compiles with make -f import.mak TARGET=pc g++ -c -DTARGET_PC -Wall -g -I /. -I /mingw/include/ -I /devstudio/vc/include -o ./pc/import.o -Wno-deprecated import.cpp import.cpp: In member function `virtual bool COUNTY::parseOb ject(BOOK&)': import.cpp:213: parse error before `>>' token
Yep :-( This line: istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population; is parsed as a function declaration followed by >> population unfortunately. This one works: istringstream is(EraseCommas( description.sub str(begIndex, endIndex - begIndex + 1))); is >> population;
Regards, Malte
--
% Randy Yates % "Though you ride on the wheels of tomorrow,
%% Fuquay-Varina, NC % you still wander the fields of your
%%% 919-577-9882 % sorrow."
%%%% <ya***@ieee.org > % '21st Century Man', *Time*, ELO http://home.earthlink.net/~yatescr
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > writes: Randy Yates wrote:
OK, why doesn't this work:
[snip]
It occured to me that someone else may have had this problem before and solved it.
I used Google
http://www.google.com/
to search for
+"C++" +"embedded commas" +"number"
and I found lots of stuff including
http://www.roguewave.com/support/doc...rwdecimal.html
Yeah, I found a lot of "stuff" too. Just like Walmart...
--
% Randy Yates % "Bird, on the wing,
%% Fuquay-Varina, NC % goes floating by
%%% 919-577-9882 % but there's a teardrop in his eye..."
%%%% <ya***@ieee.org > % 'One Summer Dream', *Face The Music*, ELO http://home.earthlink.net/~yatescr
Randy Yates wrote: Malte Starostik <ma************ *@t-online.de> writes:
Randy Yates schrieb:
OK, why doesn't this work: string EraseCommas(str ing &numericStri ng) this way it can take a temporary, like description.sub str(...) below: string EraseCommas(con st string &numericStri ng) { see above, and replace all occurances of numericString with result below: string result = numericString;
But, at the risk of being overly anal, that's not what I want to accomplish. I'd like EraseCommas(num ericString) to operate either as a stand-along function that operates on numericString,
string numericString; EraseCommas(num ericString);
or as a string
string line; string numericString; line = EraseCommas(num ericString);
It will always operate on numericString. This second example will first
modify numericString, then copy it into line. In fact, your function will
always copy numericString. The first example just ignores that copy.
Malte Starostik wrote: OK, why doesn't this work:
string EraseCommas(str ing &numericStri ng)
g++ -c -DTARGET_PC -Wall -g -I /. -I /mingw/include/ -I /devstudio/vc/include -o ./pc/import.o -Wno-deprecated import.cpp import.cpp: In member function `virtual bool COUNTY::parseOb ject(BOOK&)': import.cpp:213: parse error before `>>' token
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population; is parsed as a function declaration followed by >> population unfortunately.
How is that a function declaration? What's its name and parameter types?
It compiles just fine for me (see code below).
Maybe the OP had an error elsewhere (the error message talks
about a function COUNTY::parseOb ject(BOOK&) but the posted code
did not include such a function, perhaps he has an extra bracket
on the previous line or something.
#include <string>
#include <sstream>
using std::istringstr eam;
using std::string;
string EraseCommas(str ing &numericString) ;
int main()
{
string description;
int begIndex, endIndex, population;
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex -
begIndex + 1))) >> population;
}
Old Wolf wrote: Malte Starostik wrote: > OK, why doesn't this work: > > string EraseCommas(str ing &numericStri ng) > > g++ -c -DTARGET_PC -Wall -g -I /. -I /mingw/include/ -I > /devstudio/vc/include -o ./pc/import.o -Wno-deprecated import.cpp > import.cpp: In member function `virtual bool > COUNTY::parseOb ject(BOOK&)': import.cpp:213: parse error before `>>' > token istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population; is parsed as a function declaration followed by >> population unfortunately.
How is that a function declaration? What's its name and parameter types?
Actually, I think it's not a function declaration, but instead the
definition of an object of type istringstream with name EraseCommas, i.e.
the same as:
istringstream EraseCommas(des cription.substr (begIndex, endIndex -
begIndex + 1)) >> population;
And you cannot define a named object and directly use operator>> on it.
After splitting it up, it compiles here, too:
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex -
begIndex + 1)));
EraseCommas >> population;
It compiles just fine for me (see code below).
Really?
Maybe the OP had an error elsewhere (the error message talks about a function COUNTY::parseOb ject(BOOK&) but the posted code did not include such a function, perhaps he has an extra bracket on the previous line or something.
I rather think that the erroneous line actually is part of that function in
the OP's original code. #include <string> #include <sstream>
using std::istringstr eam; using std::string;
string EraseCommas(str ing &numericString) ;
int main() { string description; int begIndex, endIndex, population;
istringstream(E raseCommas(desc ription.substr( begIndex, endIndex - begIndex + 1))) >> population; }
That code produces the same error message as the OP's code here. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sebb |
last post by:
I'm kind of newbie to programming, but I thought of something and I
want some opinions on that.
It's about a new instruction block to do some cycles.
I thought about that because it's not very easy to program a cycle.
Here is a simple example :
b=0
|
by: rhat |
last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant.
Can anyone shed some light on what this will change and it will break stuff
as converting HTML to XHTML pages DO break things. see,
http://www.alistapart.com/articles/betterliving/
I read on
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dnnetdep/html/netfxcompat.asp
It said they changed stuff like this
|
by: Lampa Dario |
last post by:
Hi, where is this stupid error in this program? When I execute it, i
receive a segmentation fault error.
#include <stdio.h>
int main(int argc, char *argv, char *env) { int i=0; int l=0;
int word=0;
char *querystring;
querystring=malloc(sizeof(char)*100000);
if (getenv("QUERY_STRING")==NULL)
|
by: Fei Li |
last post by:
Hi,
If I'm not stupid for this, then the design of FolderBrowserDialog is very
stupid. It only allow to strat browing from several predefined
folder(Environment.SpecialFolder). What can I do if I want to start from any
folder I want?
|
by: Guoqi Zheng |
last post by:
I think I have this kind of problem very often, now it is really making me
crazy. VS.NET always want to change my html code. Ok, that is fine as long
as Vs.Net can ask my confirmaton first.
For example, I have below in header part of my html page.
<base href="http://localhost/more/">
When I click save, VS.NET change it back to <base
href="http://localhost/more"> automatically without asking me or anything.
It just remove the last "/" by...
| |
by: Adam Smith |
last post by:
I have posted this and similar questions repeatedly and can't even raise
a single response. I am being led to believe that this then 'Must be a
stupid question' although people say that there is no stupid question.
Is that another for political correctness
I am attempting an install of 7.4.3 on FreeBSD O/S 4.9, apparently
remnants of 7.3.x are scattered around on the disk from (a) previous
ports installation, causing mutex_lock/unlock,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |