visual c++ - C++ syntax error: Getting several errors expecting ';' -


this first post/question on so. following bjarne stroustrup's book "programming: principles , practice using c++", , trying 'switch'-statements. getting several syntax errors, like:

  • error c2146: syntax error : missing ';' before identifier 'value',

  • error c2143: syntax error : missing ';' before 'string', warning

  • c4552: '*' : operator has no effect; expected operator side-effect,

also, every time want use variable 'value' inside statement, a:

  • intellisense: expected ';'

error.

i using visual studio 2013 rc, , not sure why can't run program. ran similar version of week ago on osx, compiling through terminal, , ran fine. ide problem here, or code? sure rookie mistake, i'm not seeing problem. i've gone through code several time. hope can me point out rookie mistake here!..

thank input, sincerly appreciate it!

here code:

#include "../std_lib_facilities.h"  int main() {  int value = 1; double euros = 11.2; double yen = 989; double pounds = 14.2; char unit = ' ';  cout << "welcome dollars-to-other-currencies program.'\n'"; cout << "please enter unit, followed value: '\n'"; cout << "(e)uros, (y)en or (p)ounds.'\n'";  cin >> value >> unit;  switch (unit) { case 'e':     cout << value << " dollars in euros is: " value * euros ".'\n'";         break;  case 'y':     cout << value << " dollars in yen is: " value * yen ".'\n'";         break;  case 'p':     cout << value << " dollars in british pounds is: " value * pounds".'\n'";         break;  default:     cout << "computer error. not compute.'\n'";     break; } } 

add these lines @ top:

#include <iostream> using namespace std; 

you using cin , cout, haven't included header defines these names.

cout << value << " dollars in euros is: " value * euros ".'\n'"; 

you want

cout << value << " dollars in euros is: " << value * euros << ".\n"; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -