473,395 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Please help with a small question


Hi ,

I'm a newbe to programming and have a small question:

I made a small program with a class. in the class's header file I have
: double *ptr_output;

Void main()
{
double result[4];

class class_name(4); //constructor

class.method(result);
}

class.method(double *output)
{
memcpy(output,ptr_output,4);
}

class constructor
{
ptr_output = new double[length];
}
Why doesn't this work ? I want the method to peform some work on the
data and then return it to the result array.

Please help

--
Gena
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jan 10 '06 #1
1 1224
Gena wrote:
Hi ,

I'm a newbe to programming and have a small question:

I made a small program with a class. in the class's header file I have
: double *ptr_output;

Void main()
{
double result[4];

class class_name(4); //constructor

class.method(result);
}

class.method(double *output)
{
memcpy(output,ptr_output,4);


Apart from numerous syntax errors, the most obvious problem is the line
above. It should be:

memcpy(output,ptr_output,4 * sizeof ptr_output[0]);

memcpy takes a byte count, but doubles are bigger than 1 byte, so you
need to multiply up by sizeof(double). I've used sizeof ptr_output[0] in
case you ever change the type of ptr_output (e.g. to long double or float).

Why didn't you copy-and-paste your real code? Surely that's quicker than
typing it out again?

Tom
Jan 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VijayShankar | last post by:
Can u be more specific on your question Anyway its not like Session variables are available for sometime and not available for sometime. When your session starts it is very much available...
2
by: Carolyn Gill | last post by:
I have already created an asp login/database for a learning/quiz section on a small site. There will be multiple quizzes through the site and what I need now would be help: tutorials or advice that...
5
by: bojiokia | last post by:
I have started school for just 3 weeks,and totally new to c++,what i learn is just cin n cout and i received this project, omg, i am totally lost in what the question wanted me to input? ...
3
by: David Hearn | last post by:
I am using VS2005 now and have been used to the XCopy deployment way of doing things with VS2003. When I made a change to a page, I simply copied the new ASPX page up. If I made a change to the...
2
by: news.microsoft.com | last post by:
I am starting to work with ASP.NET but am finding so many options that I am getting confused and would appreciate some advice. I have developed several ACCESS databases that we use internally and...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
1
by: crazy works | last post by:
hello, i have a small hard question , i really wish to find the answer soon here because iam look for that answer for 3 days and i got no success , well , iam not a professional in the php...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.