How to scan a txt file and input into matrix c++

I have to scan a file like “6 6 2 3 5 5 1” that represents (r, c, x, y, a, b, o) where r and c is dimensions of matrix, (x,y) is position of player, (a,b) is position of goal, and o is number of obstacles. How do I go about scanning this information from a txt file? I’m new to c++ and I know how to do this in java so I’m trying to basically convert it into c++

This is what I have so far:

Board(int r, int c, int x, int y, int a, int b, int o) {
rows = r;
cols = c;
player_x = x;
player_y = y;
goal_x = a;
goal_y = b;
obstacles = o;

read_board (board *b, r, c, x, y, a, b, o){
scanf("%d %d", &(b->rows),  &(b->cols), &(b->player_x), &(b->player_y), &(b->goal_x), &(b->goal_y), &(b->obstacles)

Source: c++

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.