Unix - memoria

 
Vista:

memoria

Publicado por backgor (2 intervenciones) el 07/12/2018 04:54:15
en open sco no puedo compilar esto:

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
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <string.h>
 
#define SHMSZ     27
int shmidd,shmidt;
key_t keyd,keyt;
char *shmd, *shmt;
 
int main()
{
	char tmpd[SHMSZ];
    char oldt[SHMSZ];
    char tmpt[SHMSZ];
    keyd = 1234;
    if ((shmidd = shmget(keyd, SHMSZ, 0666)) < 0) {
        perror("shmget");
        return(1);
    }
    if ((shmd = shmat(shmidd, NULL, 0)) == (char *) -1) {
        perror("shmat");
        return(1);
    }
    keyt = 5678;
    if ((shmidt = shmget(keyt, SHMSZ,  0666)) < 0) {
        perror("shmget");
        return(1);
    }
    if ((shmt = shmat(shmidt, NULL, 0)) == (char *) -1) {
        perror("shmat");
        return(1);
    }
 
    while(1){
		strcpy(tmpt,shmt);
		if ((strcmp(tmpt,"--")!=0)&&(strcmp(oldt,tmpt)!=0)){
			fprintf(stdout,"giroscopio: %s\n",tmpt);
			strcpy(oldt,tmpt);
        }
		if (strcmp(shmd,tmpd)!=0)
			fprintf(stderr,"distancia %s\n",shmd);
		strcpy(tmpd,shmd);
 
	}
    return(0);
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder