segmentation fault on private variable

J

jeko

Hi,
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

thanks

Andrea
 
C

Chris Dollin

jeko said:
Hi,
I'm using a class method which read and write on private variable of own
class.

Since C doesn't have "class methods" or "private variables", I think you're
probably in the wrong newsgroup - try comp.lang.c++.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

Even the C++ gurus are unlikely to be able to debug code you don't show
them.
 
J

Jens.Toerring

jeko said:
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

Sorry, but it looks as if you picked the wrong newsgroup. You're here
in comg.lang.c and not comp.lang.c++ - and C doesn't have classes,
methods or private variables. But when you post there you probably
post a bit more of real code. From what you write nobody will be
able to tell you what's exactly going wrong and you might get one
of the standard-joke-answers like that the problem is on line 42...
So show at least how the class looks like, how you define the
instance of the class you're using and what you do in your com-
putations. Best would be a small, working program that exhibits the
problem (as an additional benefit one often finds the error when
one tries to cobble together such an example program).

Regards, Jens
 
J

jeko

jeko ha scritto:
Hi,
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

thanks

Andrea

Sorry, this is wrong newsgroup:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top