How can I modified the value of a string defined in a struc?
- by Eric
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!!!