![]() |
|
#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: 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
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| main.cpp:15: error: expected primary-expression before ',' token | DingbatCA | C++ Forum | 8 | 29-Oct-2007 13:52 |
| error: expected primary-expression before '.' token | Honourable Mist | C++ Forum | 11 | 18-Feb-2006 13:15 |
| error: parse error before `&' token | jake_jeckel | C++ Forum | 5 | 03-Oct-2005 10:48 |
| Replacing N'th token in a file. | kobi_hikri | C Programming Language | 2 | 24-Jun-2005 03:00 |
| storing a token pointer as a string | CoreLEx | C Programming Language | 1 | 07-Oct-2003 12:33 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The