![]() |
|
#1
|
|||
|
|||
error: expected unqualified-id before ‘{’ tokenHey all
I'm compiling another short test program to experiment with string declarations, and I get this error message: CPP / C++ / C Code:
Here's the code: CPP / C++ / C Code:
Does anyone know what I did wrong? Thanks. |
|
#2
|
||||
|
||||
Re: error: expected unqualified-id before ‘{’ tokenCPP / C++ / C Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: error: expected unqualified-id before ‘{’ tokenThanks. OK, I don't get errors anymore, but maybe I'm declaring the variable wrong or something because it only prints back one word out of the sentence it was given...? But I thought "string" would hold spaces too.
|
|
#4
|
|||
|
|||
Re: error: expected unqualified-id before ‘{’ tokenQuote:
std::string does hold more, but cin, by default, "stops" loading data into the string when it encounters a space, tab or new line. Check into using cin.getline to get the entire line. :davis: |
|
#5
|
|||
|
|||
Re: error: expected unqualified-id before ‘{’ tokenQuote:
How would I do that? |
|
#6
|
||||
|
||||
Re: error: expected unqualified-id before ‘{’ tokenLike davis said:
Quote:
http://www.cplusplus.com/reference/string/getline.html EDIT: this link's example uses the string type with getline. or, from the same site, for what davis suggested: http://www.cplusplus.com/reference/i...m/getline.html EDIT: this link's example uses character arrays with cin.getline __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
Observations of Iraq by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting PHP to C and I need a little help | Allenport | C Programming Language | 4 | 14-Aug-2006 13:38 |
| Need help with enums and function program | rho | C++ Forum | 8 | 27-Jun-2005 19:13 |
| Replacing N'th token in a file. | kobi_hikri | C Programming Language | 2 | 24-Jun-2005 02:00 |
| storing a token pointer as a string | CoreLEx | C Programming Language | 1 | 07-Oct-2003 11:33 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The