
Infracción de acceso al escribir en la ubicación 0x0000006c.
Publicado por flavio (1 intervención) el 31/12/2015 21:35:43
estoy haciendo un juego de snake y me esta generando un error de doble apuntador cuando lo voy a asignar en un procedimiento La idea es que se mueva a la derecha
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include <time.h>
#include <windows.h>
void mostrar(char *tablero)
{
for (int i=0;i<9;i++)
{
for (int e=0;e<9;e++,tablero++)
printf("(%c)",*tablero);
printf("\n");
}
}
void movderecha(char **serp)
{
printf("%c",**serp);
**serp=' ';
*serp++;fflush(stdin);
getch();
**serp='l';
}
void mov(char *tablero,char *serpi,int x)
{
if (x!='p')
{
mostrar(tablero);
Sleep(1500);
if (_kbhit())
{
x=getch();
if (x==108)
{ printf("if \n");movderecha(&serpi);}
}
else
{ printf("else \n");movderecha(&serpi);}
getch();
system("cls");
mov(tablero,serpi,x);
}
}
void main()
{
char c[9][9],*p;
for (int i=0;i<9;i++)
for (int e=0;e<9;e++)
c[i][e]=' ';
p=&c[2][1];
*p='p';
mov(&c[0][0],p,getch());
system("pause");
}
el procedimiento SÓLO funciona si esta escrito de esta manera ....
void mov(char *tablero,char *serpi,int x)
{
if (x!='p')
{
mostrar(tablero);
Sleep(1500);
if (_kbhit())
{
x=getch();
if (x==108)
{serpi=' ';
serpi++
serpi='l';}
}
else
{ serpi=' ';
serpi++
serpi='l';}
getch();
system("cls");
mov(tablero,serpi,x);
}
}
Valora esta pregunta


0