How can I modified the value of a string defined in a struc?

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2010-04-21T17:00:12Z Indexed on 2010/04/21 17:03 UTC
Read the original article Hit count: 249

Filed under:
|

Hi,

I have the following code in c++:

define TAM 4000

define NUMPAGS 512

struct pagina { bitset<12> direccion; char operacion; char permiso; string *dato; int numero; };

void crearPagina(pagina* pag[], int pos, int dir) { pagina * paginas = (pagina*)malloc(sizeof(char) * TAM); paginas -> direccion = bitset<12> (dir); paginas -> operacion = 'n'; paginas -> permiso = 'n';
string **tempDato = &paginas -> dato; char *temp = " "; **tempDato = temp; paginas -> numero = 0; pag[pos] = paginas;
}

I want to modify the value of the variable called "string *dato" in the struct pagina but, everytime I want to assing a new value, the compiler throws a segmentation fault. In this case I'm using a pointer to string, but I have also tried with a string.

In a few words I want to do the following: pagina -> dato = "test";

Any idea?

Thanks in advance!!!

© Stack Overflow or respective owner

Related posts about c++

Related posts about string