C problem struct and string


Posted on 16th Feb 2014 07:03 pm by admin

Hi guys,

This is my first post and I'm hoping the experts here can help me solve my problem.

- I'm trying to create a linked list in C and the codes look like this:

#include "stdio.h"
#include
#include
using namespace std;

struct dir_list
{
int level;
string dir_name;
struct dir_list * head;
struct dir_list * tail;
};

typedef struct dir_list * dir;

void main()
{
dir curr;

curr=(dir)malloc(sizeof(string)+sizeof(dir));
curr->level=0;
curr->dir_name="test ";
curr->head=NULL;
curr->tail=NULL;
}

The problem with this code happens at the string assignment curr->dir_name="test "; and the executable will stop responding once run. I suspect the problem could be caused by the size of malloc but the result stays the same after I increased that number.

Can anyone explain to me what the problem is?

Greatly appreciated!

No comments posted yet

Your Answer:

Login to answer
329 Like 5 Dislike
Previous forums Next forums
Other forums

modifying a property of an object from a different class
I have 2 classes:
- Math
- Distance

in my math class, I have this line:
$distance =

TimeStamp Column Problem...
I'm mad at my self and thinking I'm a little retarded. It just be some one mistake I'm missing here.

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

what does this mean? +=
is anyone able to explain what this code is saying?

i had it written for me awhile back and n

How to add advertisment on top of videos
Hello,
I was told that i should find the answer for this problem in this forums.
I searched a

Collecting AOL Search Terms
I am attempting to collect AOL search terms. I know the code is correct (it works for google, bing,

Wierd echo error?
Hi, i got the most wierd php error ever and i don't know why..
Code: echo "<t

I didnt code this but I need help with it
I'm sorry. i'm not a coder. I have this script for forcing download and previewing mp3. The guy that

IP question
ive got 2 ip addresses both global from same user how would i detect if they are local to each other

Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
I trying run
create or replace package ....etc.

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash