C++ function argument and struct errors -


i coding program allow user input direction , move robot along coordinate plane. new c++, few of errors getting confusing me. please explain errors?

when call function init_room, says there few arguments. same thing happens when call init_robot. both have pointer parameters. how go fixing issue?

when call function move in main function, says expression must modifiable value. mean?

thanks help!

    #include <iostream>  using namespace std;  typedef struct room {     int x;     int y; };  typedef struct robot {     room *current_room;     int current_x;     int current_y;     int model; };  void init_robot(robot *r) {     r->current_room->x;     r->current_room->y;     r->current_x = 0;     r->current_y = 0;     //assign model number     r->model; }  void init_room(room *r) {     cin >> r->x;     cin >> r->y;  }  char move(robot *r, int direction) {         if (direction == 'n' || direction == 'n')         {             r->current_y + 1;         }         else if (direction == 's' || direction == 's')         {             r->current_y - 1;         }         else if (direction == 'e' || direction == 'e')         {             r->current_x + 1;         }         else if (direction == 'w' || direction == 'w')         {             r->current_x - 1;         }         else         {             direction = 'x';             return direction;         }      int main() {         char direction;         char restart;          cout << "what size room be?";          room rr;          init_room();          robot r; initrobot();          while (true) {                  cout << "your robot in room dimensions (" << rr.x << "," << rr.yy << "). @ location (" << r.current_x << "," << r.current_y << ")." << endl;                 cout << "what direction move? n (north), e (east), s(south), or w(west)?";                 {                 cin >> direction;                  move(direction) = direction;                 if (direction = 'x') {                     cout << "invalid direction. please enter n, e, s, or w.";                     }                 while (direction == 'x');                  cout << "current position is" << endl;      //          if (r.current_x <= rr.x && r.current_y <= rr.y)         //      {             //      cout << "error, robot out of room bounds. robot has exited room. enter room? y or n?";                     cin >> restart;             //} while (restart == 'y' || restart == 'y');                     }              system("pause");             return 0;         } 

the functions init_room , init_robot both take single parameter each. so, calls them should like

init_room(&rr); init_robot(&r); 

move returns rvalue of type char, , rvalues cannot modified. can used input other expression. expect not know rvalue , idea research important concept in c++. (quick version: rvalue might on right side of = , read-only.)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -