Hi,
I am having issues with assigning a value to a string. I have two structures node and edge as follows:
struct node{
string name;
int key;
};
struct edge
{
node u;
node v;
int weight;
edge *link;
}*front = NULL;
Now I have a function that I am using to create a priority queue to order edges according to their weights, however whenever I try to assign a value to a name attribute of a node the program crashes:
void insert_pque(string a1, string a2, int i,int j,int wt)
{
edge *tmp,*q;
tmp = (edge *)malloc(sizeof(edge));
tmp->u.key=i;
[B]tmp->v.name = a2; // CRASHES HERE!!! [/B]
tmp->v.key=j;
tmp->weight = wt;
...
}
When debugging crash message from memcpy.asm:
TrailUp1:
mov al,[esi] ;U - get byte from source
;V - spare
mov [edi],al ;U - put byte in destination
mov eax,[dst] ;V - return pointer to destination
pop esi ;U - restore esi
pop edi ;V - restore edi
M_EXIT
When I use simple char as type for the name everything works fine, however when I try using strings it crashes ! :(
Any help would be much appreciated,
Thanks
Deflamol