473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(re sult);
}

class.method(do uble *output)
{
memcpy(output,p tr_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 1242
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(re sult);
}

class.method(do uble *output)
{
memcpy(output,p tr_output,4);


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

memcpy(output,p tr_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
3198
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 unless your session ends One more thing Session variables can very much be used in Application events
2
1855
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 a complete novice can understand/follow to create the following: A small simple quiz--for now each has just one question with 5 multi-choice buttons. On submit should send the answer to A) a database (using access for now) to track scoring...
5
1303
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? http://s22.yousendit.com/d.aspx?id=0FJE4MQAJUPW20FJCSFIEQ6VES Is thre any one who k help me with it? do email me at bb32_fong@yahoo.com.sg
3
1424
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 code behind, I would copy the new DLL to the BIN directory and obviously, if I made a change to both, I copied both. Now with VS2005, I have figured out the publish thing and it works fine except that when I publish a site, it deletes everything in...
2
1397
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 ASP pages to make some of the information available on our company website - this works very well and I like the flexibility of both Access forms and ASP web Our site has low traffic with never more than 3 on at any time - mostly I get...
1
9652
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
24
2896
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 are structs, where classes are on the heap... when value types go out of scope the memory is re- allocated, object remain in memory waiting to be cleaned up by the garbage collector, etc, but he responded 'so why not just put say a class on the...
1
1041
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 programming but iam trying to be good as i can on it so about the question , just iam trying to complete my second script programming , i want to make adding topics system , i want to let the visitor be able to add any mount of pictures inside...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.