Visual Studio crashing help!!!!!!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int x,y;
}T_position;


void  set_position(T_position *pos, int row, int col); // acquires 2 numbers and assigns them to 'x' and 'y'
void  get_position(const T_position *pos, int *row, int *col); // extracts the number from 'x' and 'y'

int main(void)
{
    int a=1, b=2;
    int *row_a, *col_b;

    T_position pos;
    T_position *acquired_pos;
    acquired_pos = &pos;

    set_position(acquired_pos,a,b);
    printf("%d",acquired_pos->x);// is supposed to show '1' and '2' from 'a' and 'b'
    printf("%d",acquired_pos->y);

    get_position(acquired_pos,row_a, col_b); // is supposed to show '1' and '2' from 'acquired_pos->x' and acquired_pos->y'
    printf("%d", row_a);
    printf("%d", col_b);

    system("pause");
    return EXIT_SUCCESS;
}


void  set_position(T_position *pos, int row, int col)
{
    pos->x = row;
    pos->y = col;
}

void  get_position(const T_position *pos, int *row, int *col)
{
    *row = pos->x;
    *col = pos->y;
}


Why is this making my MVS crash? and what did I do wrong in my main? The functions are given in class and are supposedly correct... I jst want to show 1 &2 twice with this....
row_a and row_b aren't pointing to anything, so when you call get_position, it'll crash your program.

You want something like:
1
2
3
int row_a, row_b; // Not pointers
// Do your other stuff
get_position(acquired_pos, &row_a, &row_b);
Thanks!
Topic archived. No new replies allowed.